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
MegaMilionsGangstarApes
MegaMilionsGangstarApes.sol
0x3af32fd45224c502469af10e8fff285c18a978bc
Solidity
ERC721Enumerable
abstract contract ERC721Enumerable is ERC721, IERC721Enumerable { // Mapping from owner to list of owned token IDs mapping(address => mapping(uint256 => uint256)) private _ownedTokens; // Mapping from token ID to index of the owner tokens list mapping(uint256 => uint256) private _ownedTokensIndex; // Array with all token ids, used for enumeration uint256[] private _allTokens; // Mapping from token id to position in the allTokens array mapping(uint256 => uint256) private _allTokensIndex; /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(IERC165, ERC721) returns (bool) { return interfaceId == type(IERC721Enumerable).interfaceId || super.supportsInterface(interfaceId); } /** * @dev See {IERC721Enumerable-tokenOfOwnerByIndex}. */ function tokenOfOwnerByIndex(address owner, uint256 index) public view virtual override returns (uint256) { require(index < ERC721.balanceOf(owner), "ERC721Enumerable: owner index out of bounds"); return _ownedTokens[owner][index]; } /** * @dev See {IERC721Enumerable-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { return _allTokens.length; } /** * @dev See {IERC721Enumerable-tokenByIndex}. */ function tokenByIndex(uint256 index) public view virtual override returns (uint256) { require(index < ERC721Enumerable.totalSupply(), "ERC721Enumerable: global index out of bounds"); return _allTokens[index]; } /** * @dev Hook that is called before any token transfer. This includes minting * and burning. * * Calling conditions: * * - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be * transferred to `to`. * - When `from` is zero, `tokenId` will be minted for `to`. * - When `to` is zero, ``from``'s `tokenId` will be burned. * - `from` cannot be the zero address. * - `to` cannot be the zero address. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address from, address to, uint256 tokenId ) internal virtual override { super._beforeTokenTransfer(from, to, tokenId); if (from == address(0)) { _addTokenToAllTokensEnumeration(tokenId); } else if (from != to) { _removeTokenFromOwnerEnumeration(from, tokenId); } if (to == address(0)) { _removeTokenFromAllTokensEnumeration(tokenId); } else if (to != from) { _addTokenToOwnerEnumeration(to, tokenId); } } /** * @dev Private function to add a token to this extension's ownership-tracking data structures. * @param to address representing the new owner of the given token ID * @param tokenId uint256 ID of the token to be added to the tokens list of the given address */ function _addTokenToOwnerEnumeration(address to, uint256 tokenId) private { uint256 length = ERC721.balanceOf(to); _ownedTokens[to][length] = tokenId; _ownedTokensIndex[tokenId] = length; } /** * @dev Private function to add a token to this extension's token tracking data structures. * @param tokenId uint256 ID of the token to be added to the tokens list */ function _addTokenToAllTokensEnumeration(uint256 tokenId) private { _allTokensIndex[tokenId] = _allTokens.length; _allTokens.push(tokenId); } /** * @dev Private function to remove a token from this extension's ownership-tracking data structures. Note that * while the token is not assigned a new owner, the `_ownedTokensIndex` mapping is _not_ updated: this allows for * gas optimizations e.g. when performing a transfer operation (avoiding double writes). * This has O(1) time complexity, but alters the order of the _ownedTokens array. * @param from address representing the previous owner of the given token ID * @param tokenId uint256 ID of the token to be removed from the tokens list of the given address */ function _removeTokenFromOwnerEnumeration(address from, uint256 tokenId) private { // To prevent a gap in from's tokens array, we store the last token in the index of the token to delete, and // then delete the last slot (swap and pop). uint256 lastTokenIndex = ERC721.balanceOf(from) - 1; uint256 tokenIndex = _ownedTokensIndex[tokenId]; // When the token to delete is the last token, the swap operation is unnecessary if (tokenIndex != lastTokenIndex) { uint256 lastTokenId = _ownedTokens[from][lastTokenIndex]; _ownedTokens[from][tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token _ownedTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index } // This also deletes the contents at the last position of the array delete _ownedTokensIndex[tokenId]; delete _ownedTokens[from][lastTokenIndex]; } /** * @dev Private function to remove a token from this extension's token tracking data structures. * This has O(1) time complexity, but alters the order of the _allTokens array. * @param tokenId uint256 ID of the token to be removed from the tokens list */ function _removeTokenFromAllTokensEnumeration(uint256 tokenId) private { // To prevent a gap in the tokens array, we store the last token in the index of the token to delete, and // then delete the last slot (swap and pop). uint256 lastTokenIndex = _allTokens.length - 1; uint256 tokenIndex = _allTokensIndex[tokenId]; // When the token to delete is the last token, the swap operation is unnecessary. However, since this occurs so // rarely (when the last minted token is burnt) that we still do the swap here to avoid the gas cost of adding // an 'if' statement (like in _removeTokenFromOwnerEnumeration) uint256 lastTokenId = _allTokens[lastTokenIndex]; _allTokens[tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token _allTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index // This also deletes the contents at the last position of the array delete _allTokensIndex[tokenId]; _allTokens.pop(); } }
/** * @dev This implements an optional extension of {ERC721} defined in the EIP that adds * enumerability of all the token ids in the contract as well as all token ids owned by each * account. */
NatSpecMultiLine
_removeTokenFromAllTokensEnumeration
function _removeTokenFromAllTokensEnumeration(uint256 tokenId) private { // To prevent a gap in the tokens array, we store the last token in the index of the token to delete, and // then delete the last slot (swap and pop). uint256 lastTokenIndex = _allTokens.length - 1; uint256 tokenIndex = _allTokensIndex[tokenId]; // When the token to delete is the last token, the swap operation is unnecessary. However, since this occurs so // rarely (when the last minted token is burnt) that we still do the swap here to avoid the gas cost of adding // an 'if' statement (like in _removeTokenFromOwnerEnumeration) uint256 lastTokenId = _allTokens[lastTokenIndex]; _allTokens[tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token _allTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index // This also deletes the contents at the last position of the array delete _allTokensIndex[tokenId]; _allTokens.pop(); }
/** * @dev Private function to remove a token from this extension's token tracking data structures. * This has O(1) time complexity, but alters the order of the _allTokens array. * @param tokenId uint256 ID of the token to be removed from the tokens list */
NatSpecMultiLine
v0.8.7+commit.e28d00a7
MIT
ipfs://414d9951eb094e9f3eecc45ff7dcf1c7de317858d1ad8616b1355e70b4b69e2c
{ "func_code_index": [ 5667, 6751 ] }
58,661
MegaMilionsGangstarApes
MegaMilionsGangstarApes.sol
0x3af32fd45224c502469af10e8fff285c18a978bc
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); }
/** * @dev Interface of the ERC20 standard as defined in the EIP. */
NatSpecMultiLine
totalSupply
function totalSupply() external view returns (uint256);
/** * @dev Returns the amount of tokens in existence. */
NatSpecMultiLine
v0.8.7+commit.e28d00a7
MIT
ipfs://414d9951eb094e9f3eecc45ff7dcf1c7de317858d1ad8616b1355e70b4b69e2c
{ "func_code_index": [ 94, 154 ] }
58,662
MegaMilionsGangstarApes
MegaMilionsGangstarApes.sol
0x3af32fd45224c502469af10e8fff285c18a978bc
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); }
/** * @dev Interface of the ERC20 standard as defined in the EIP. */
NatSpecMultiLine
balanceOf
function balanceOf(address account) external view returns (uint256);
/** * @dev Returns the amount of tokens owned by `account`. */
NatSpecMultiLine
v0.8.7+commit.e28d00a7
MIT
ipfs://414d9951eb094e9f3eecc45ff7dcf1c7de317858d1ad8616b1355e70b4b69e2c
{ "func_code_index": [ 237, 310 ] }
58,663
MegaMilionsGangstarApes
MegaMilionsGangstarApes.sol
0x3af32fd45224c502469af10e8fff285c18a978bc
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); }
/** * @dev Interface of the ERC20 standard as defined in the EIP. */
NatSpecMultiLine
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.8.7+commit.e28d00a7
MIT
ipfs://414d9951eb094e9f3eecc45ff7dcf1c7de317858d1ad8616b1355e70b4b69e2c
{ "func_code_index": [ 534, 616 ] }
58,664
MegaMilionsGangstarApes
MegaMilionsGangstarApes.sol
0x3af32fd45224c502469af10e8fff285c18a978bc
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); }
/** * @dev Interface of the ERC20 standard as defined in the EIP. */
NatSpecMultiLine
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.8.7+commit.e28d00a7
MIT
ipfs://414d9951eb094e9f3eecc45ff7dcf1c7de317858d1ad8616b1355e70b4b69e2c
{ "func_code_index": [ 895, 983 ] }
58,665
MegaMilionsGangstarApes
MegaMilionsGangstarApes.sol
0x3af32fd45224c502469af10e8fff285c18a978bc
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); }
/** * @dev Interface of the ERC20 standard as defined in the EIP. */
NatSpecMultiLine
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.8.7+commit.e28d00a7
MIT
ipfs://414d9951eb094e9f3eecc45ff7dcf1c7de317858d1ad8616b1355e70b4b69e2c
{ "func_code_index": [ 1647, 1726 ] }
58,666
MegaMilionsGangstarApes
MegaMilionsGangstarApes.sol
0x3af32fd45224c502469af10e8fff285c18a978bc
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); }
/** * @dev Interface of the ERC20 standard as defined in the EIP. */
NatSpecMultiLine
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.8.7+commit.e28d00a7
MIT
ipfs://414d9951eb094e9f3eecc45ff7dcf1c7de317858d1ad8616b1355e70b4b69e2c
{ "func_code_index": [ 2039, 2175 ] }
58,667
MegaMilionsGangstarApes
MegaMilionsGangstarApes.sol
0x3af32fd45224c502469af10e8fff285c18a978bc
Solidity
SafeERC20
library SafeERC20 { using Address for address; function safeTransfer( IERC20 token, address to, uint256 value ) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); } function safeTransferFrom( IERC20 token, address from, address to, uint256 value ) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value)); } /** * @dev Deprecated. This function has issues similar to the ones found in * {IERC20-approve}, and its usage is discouraged. * * Whenever possible, use {safeIncreaseAllowance} and * {safeDecreaseAllowance} instead. */ function safeApprove( IERC20 token, address spender, uint256 value ) internal { // safeApprove should only be called when setting an initial allowance, // or when resetting it to zero. To increase and decrease it, use // 'safeIncreaseAllowance' and 'safeDecreaseAllowance' require( (value == 0) || (token.allowance(address(this), spender) == 0), "SafeERC20: approve from non-zero to non-zero allowance" ); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value)); } function safeIncreaseAllowance( IERC20 token, address spender, uint256 value ) internal { uint256 newAllowance = token.allowance(address(this), spender) + value; _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } function safeDecreaseAllowance( IERC20 token, address spender, uint256 value ) internal { unchecked { uint256 oldAllowance = token.allowance(address(this), spender); require(oldAllowance >= value, "SafeERC20: decreased allowance below zero"); uint256 newAllowance = oldAllowance - value; _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } } /** * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement * on the return value: the return value is optional (but if data is returned, it must not be false). * @param token The token targeted by the call. * @param data The call data (encoded using abi.encode or one of its variants). */ function _callOptionalReturn(IERC20 token, bytes memory data) private { // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since // we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that // the target address contains contract code and also asserts for success in the low-level call. bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed"); if (returndata.length > 0) { // Return data is optional require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed"); } } }
/** * @title SafeERC20 * @dev Wrappers around ERC20 operations that throw on failure (when the token * contract returns false). Tokens that return no value (and instead revert or * throw on failure) are also supported, non-reverting calls are assumed to be * successful. * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract, * which allows you to call the safe operations as `token.safeTransfer(...)`, etc. */
NatSpecMultiLine
safeApprove
function safeApprove( IERC20 token, address spender, uint256 value ) internal { // safeApprove should only be called when setting an initial allowance, // or when resetting it to zero. To increase and decrease it, use // 'safeIncreaseAllowance' and 'safeDecreaseAllowance' require( (value == 0) || (token.allowance(address(this), spender) == 0), "SafeERC20: approve from non-zero to non-zero allowance" ); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value)); }
/** * @dev Deprecated. This function has issues similar to the ones found in * {IERC20-approve}, and its usage is discouraged. * * Whenever possible, use {safeIncreaseAllowance} and * {safeDecreaseAllowance} instead. */
NatSpecMultiLine
v0.8.7+commit.e28d00a7
MIT
ipfs://414d9951eb094e9f3eecc45ff7dcf1c7de317858d1ad8616b1355e70b4b69e2c
{ "func_code_index": [ 791, 1412 ] }
58,668
MegaMilionsGangstarApes
MegaMilionsGangstarApes.sol
0x3af32fd45224c502469af10e8fff285c18a978bc
Solidity
SafeERC20
library SafeERC20 { using Address for address; function safeTransfer( IERC20 token, address to, uint256 value ) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); } function safeTransferFrom( IERC20 token, address from, address to, uint256 value ) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value)); } /** * @dev Deprecated. This function has issues similar to the ones found in * {IERC20-approve}, and its usage is discouraged. * * Whenever possible, use {safeIncreaseAllowance} and * {safeDecreaseAllowance} instead. */ function safeApprove( IERC20 token, address spender, uint256 value ) internal { // safeApprove should only be called when setting an initial allowance, // or when resetting it to zero. To increase and decrease it, use // 'safeIncreaseAllowance' and 'safeDecreaseAllowance' require( (value == 0) || (token.allowance(address(this), spender) == 0), "SafeERC20: approve from non-zero to non-zero allowance" ); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value)); } function safeIncreaseAllowance( IERC20 token, address spender, uint256 value ) internal { uint256 newAllowance = token.allowance(address(this), spender) + value; _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } function safeDecreaseAllowance( IERC20 token, address spender, uint256 value ) internal { unchecked { uint256 oldAllowance = token.allowance(address(this), spender); require(oldAllowance >= value, "SafeERC20: decreased allowance below zero"); uint256 newAllowance = oldAllowance - value; _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } } /** * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement * on the return value: the return value is optional (but if data is returned, it must not be false). * @param token The token targeted by the call. * @param data The call data (encoded using abi.encode or one of its variants). */ function _callOptionalReturn(IERC20 token, bytes memory data) private { // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since // we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that // the target address contains contract code and also asserts for success in the low-level call. bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed"); if (returndata.length > 0) { // Return data is optional require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed"); } } }
/** * @title SafeERC20 * @dev Wrappers around ERC20 operations that throw on failure (when the token * contract returns false). Tokens that return no value (and instead revert or * throw on failure) are also supported, non-reverting calls are assumed to be * successful. * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract, * which allows you to call the safe operations as `token.safeTransfer(...)`, etc. */
NatSpecMultiLine
_callOptionalReturn
function _callOptionalReturn(IERC20 token, bytes memory data) private { // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since // we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that // the target address contains contract code and also asserts for success in the low-level call. bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed"); if (returndata.length > 0) { // Return data is optional require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed"); } }
/** * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement * on the return value: the return value is optional (but if data is returned, it must not be false). * @param token The token targeted by the call. * @param data The call data (encoded using abi.encode or one of its variants). */
NatSpecMultiLine
v0.8.7+commit.e28d00a7
MIT
ipfs://414d9951eb094e9f3eecc45ff7dcf1c7de317858d1ad8616b1355e70b4b69e2c
{ "func_code_index": [ 2628, 3349 ] }
58,669
MegaMilionsGangstarApes
MegaMilionsGangstarApes.sol
0x3af32fd45224c502469af10e8fff285c18a978bc
Solidity
PaymentSplitter
contract PaymentSplitter is Context { event PayeeAdded(address account, uint256 shares); event PaymentReleased(address to, uint256 amount); event ERC20PaymentReleased(IERC20 indexed token, address to, uint256 amount); event PaymentReceived(address from, uint256 amount); event Warning(string message); uint256 private _totalShares = 50000; uint256 private _totalReleased; mapping(address => uint256) private _shares; mapping(address => uint256) private _released; address[] private _payees; mapping(IERC20 => uint256) private _erc20TotalReleased; mapping(IERC20 => mapping(address => uint256)) private _erc20Released; /** * @dev Creates an instance of `PaymentSplitter` where each account in `payees` is assigned the number of shares at * the matching position in the `shares` array. * * All addresses in `payees` must be non-zero. Both arrays must have the same non-zero length, and there must be no * duplicates in `payees`. */ constructor(address[] memory payees, uint256[] memory shares_) payable { require(payees.length == shares_.length, "PaymentSplitter: payees and shares length mismatch"); require(payees.length > 0, "PaymentSplitter: no payees"); for (uint256 i = 0; i < payees.length; i++) { _addPayee(payees[i], shares_[i]); } } /** * @dev The Ether received will be logged with {PaymentReceived} events. Note that these events are not fully * reliable: it's possible for a contract to receive Ether without triggering this function. This only affects the * reliability of the events, and not the actual splitting of Ether. * * To learn more about this see the Solidity documentation for * https://solidity.readthedocs.io/en/latest/contracts.html#fallback-function[fallback * functions]. */ receive() external payable virtual { emit PaymentReceived(_msgSender(), msg.value); } function addToReleased(uint256 amount) internal { _totalReleased += amount; } /** * @dev Getter for the total shares held by payees. */ function totalShares() public view returns (uint256) { return _totalShares; } /** * @dev Getter for the total amount of Ether already released. */ function totalReleased() public view returns (uint256) { return _totalReleased; } /** * @dev Getter for the total amount of `token` already released. `token` should be the address of an IERC20 * contract. */ function totalReleased(IERC20 token) public view returns (uint256) { return _erc20TotalReleased[token]; } /** * @dev Getter for the amount of shares held by an account. */ function shares(address account) public view returns (uint256) { return _shares[account]; } /** * @dev Getter for the amount of Ether already released to a payee. */ function released(address account) public view returns (uint256) { return _released[account]; } /** * @dev Getter for the amount of `token` tokens already released to a payee. `token` should be the address of an * IERC20 contract. */ function released(IERC20 token, address account) public view returns (uint256) { return _erc20Released[token][account]; } /** * @dev Getter for the address of the payee number `index`. */ function payee(uint256 index) public view returns (address) { return _payees[index]; } /** * @dev Triggers a transfer to `account` of the amount of Ether they are owed, according to their percentage of the * total shares and their previous withdrawals. */ function release(address payable account) public virtual { require(_shares[account] > 0, "PaymentSplitter: account has no shares"); uint256 totalReceived = address(this).balance + totalReleased(); uint256 payment = _pendingPayment(account, totalReceived, released(account)); if (payment != 0) { _released[account] += payment; _totalReleased += payment; Address.sendValue(account, payment); emit PaymentReleased(account, payment); } else { emit Warning("PaymentSplitter: account is not due payment"); } } /** * @dev Triggers a transfer to `account` of the amount of `token` tokens they are owed, according to their * percentage of the total shares and their previous withdrawals. `token` must be the address of an IERC20 * contract. */ function release(IERC20 token, address account) public virtual { require(_shares[account] > 0, "PaymentSplitter: account has no shares"); uint256 totalReceived = token.balanceOf(address(this)) + totalReleased(token); uint256 payment = _pendingPayment(account, totalReceived, released(token, account)); if (payment != 0) { _erc20Released[token][account] += payment; _erc20TotalReleased[token] += payment; SafeERC20.safeTransfer(token, account, payment); emit ERC20PaymentReleased(token, account, payment); } else { emit Warning("PaymentSplitter: account is not due payment"); } } /** * @dev internal logic for computing the pending payment of an `account` given the token historical balances and * already released amounts. */ function _pendingPayment( address account, uint256 totalReceived, uint256 alreadyReleased ) private view returns (uint256) { return (totalReceived * _shares[account]) / _totalShares - alreadyReleased; } /** * @dev Add a new payee to the contract. * @param account The address of the payee to add. * @param shares_ The number of shares owned by the payee. */ function _addPayee(address account, uint256 shares_) private { require(account != address(0), "PaymentSplitter: account is the zero address"); require(shares_ > 0, "PaymentSplitter: shares are 0"); require(_shares[account] == 0, "PaymentSplitter: account already has shares"); _payees.push(account); _shares[account] = shares_; _totalShares = _totalShares + shares_; emit PayeeAdded(account, shares_); } }
/** * @title PaymentSplitter * @dev This contract allows to split Ether payments among a group of accounts. The sender does not need to be aware * that the Ether will be split in this way, since it is handled transparently by the contract. * * The split can be in equal parts or in any other arbitrary proportion. The way this is specified is by assigning each * account to a number of shares. Of all the Ether that this contract receives, each account will then be able to claim * an amount proportional to the percentage of total shares they were assigned. * * `PaymentSplitter` follows a _pull payment_ model. This means that payments are not automatically forwarded to the * accounts but kept in this contract, and the actual transfer is triggered as a separate step by calling the {release} * function. * * NOTE: This contract assumes that ERC20 tokens will behave similarly to native tokens (Ether). Rebasing tokens, and * tokens that apply fees during transfers, are likely to not be supported as expected. If in doubt, we encourage you * to run tests before sending real value to this contract. */
NatSpecMultiLine
/** * @dev The Ether received will be logged with {PaymentReceived} events. Note that these events are not fully * reliable: it's possible for a contract to receive Ether without triggering this function. This only affects the * reliability of the events, and not the actual splitting of Ether. * * To learn more about this see the Solidity documentation for * https://solidity.readthedocs.io/en/latest/contracts.html#fallback-function[fallback * functions]. */
NatSpecMultiLine
v0.8.7+commit.e28d00a7
MIT
ipfs://414d9951eb094e9f3eecc45ff7dcf1c7de317858d1ad8616b1355e70b4b69e2c
{ "func_code_index": [ 1929, 2033 ] }
58,670
MegaMilionsGangstarApes
MegaMilionsGangstarApes.sol
0x3af32fd45224c502469af10e8fff285c18a978bc
Solidity
PaymentSplitter
contract PaymentSplitter is Context { event PayeeAdded(address account, uint256 shares); event PaymentReleased(address to, uint256 amount); event ERC20PaymentReleased(IERC20 indexed token, address to, uint256 amount); event PaymentReceived(address from, uint256 amount); event Warning(string message); uint256 private _totalShares = 50000; uint256 private _totalReleased; mapping(address => uint256) private _shares; mapping(address => uint256) private _released; address[] private _payees; mapping(IERC20 => uint256) private _erc20TotalReleased; mapping(IERC20 => mapping(address => uint256)) private _erc20Released; /** * @dev Creates an instance of `PaymentSplitter` where each account in `payees` is assigned the number of shares at * the matching position in the `shares` array. * * All addresses in `payees` must be non-zero. Both arrays must have the same non-zero length, and there must be no * duplicates in `payees`. */ constructor(address[] memory payees, uint256[] memory shares_) payable { require(payees.length == shares_.length, "PaymentSplitter: payees and shares length mismatch"); require(payees.length > 0, "PaymentSplitter: no payees"); for (uint256 i = 0; i < payees.length; i++) { _addPayee(payees[i], shares_[i]); } } /** * @dev The Ether received will be logged with {PaymentReceived} events. Note that these events are not fully * reliable: it's possible for a contract to receive Ether without triggering this function. This only affects the * reliability of the events, and not the actual splitting of Ether. * * To learn more about this see the Solidity documentation for * https://solidity.readthedocs.io/en/latest/contracts.html#fallback-function[fallback * functions]. */ receive() external payable virtual { emit PaymentReceived(_msgSender(), msg.value); } function addToReleased(uint256 amount) internal { _totalReleased += amount; } /** * @dev Getter for the total shares held by payees. */ function totalShares() public view returns (uint256) { return _totalShares; } /** * @dev Getter for the total amount of Ether already released. */ function totalReleased() public view returns (uint256) { return _totalReleased; } /** * @dev Getter for the total amount of `token` already released. `token` should be the address of an IERC20 * contract. */ function totalReleased(IERC20 token) public view returns (uint256) { return _erc20TotalReleased[token]; } /** * @dev Getter for the amount of shares held by an account. */ function shares(address account) public view returns (uint256) { return _shares[account]; } /** * @dev Getter for the amount of Ether already released to a payee. */ function released(address account) public view returns (uint256) { return _released[account]; } /** * @dev Getter for the amount of `token` tokens already released to a payee. `token` should be the address of an * IERC20 contract. */ function released(IERC20 token, address account) public view returns (uint256) { return _erc20Released[token][account]; } /** * @dev Getter for the address of the payee number `index`. */ function payee(uint256 index) public view returns (address) { return _payees[index]; } /** * @dev Triggers a transfer to `account` of the amount of Ether they are owed, according to their percentage of the * total shares and their previous withdrawals. */ function release(address payable account) public virtual { require(_shares[account] > 0, "PaymentSplitter: account has no shares"); uint256 totalReceived = address(this).balance + totalReleased(); uint256 payment = _pendingPayment(account, totalReceived, released(account)); if (payment != 0) { _released[account] += payment; _totalReleased += payment; Address.sendValue(account, payment); emit PaymentReleased(account, payment); } else { emit Warning("PaymentSplitter: account is not due payment"); } } /** * @dev Triggers a transfer to `account` of the amount of `token` tokens they are owed, according to their * percentage of the total shares and their previous withdrawals. `token` must be the address of an IERC20 * contract. */ function release(IERC20 token, address account) public virtual { require(_shares[account] > 0, "PaymentSplitter: account has no shares"); uint256 totalReceived = token.balanceOf(address(this)) + totalReleased(token); uint256 payment = _pendingPayment(account, totalReceived, released(token, account)); if (payment != 0) { _erc20Released[token][account] += payment; _erc20TotalReleased[token] += payment; SafeERC20.safeTransfer(token, account, payment); emit ERC20PaymentReleased(token, account, payment); } else { emit Warning("PaymentSplitter: account is not due payment"); } } /** * @dev internal logic for computing the pending payment of an `account` given the token historical balances and * already released amounts. */ function _pendingPayment( address account, uint256 totalReceived, uint256 alreadyReleased ) private view returns (uint256) { return (totalReceived * _shares[account]) / _totalShares - alreadyReleased; } /** * @dev Add a new payee to the contract. * @param account The address of the payee to add. * @param shares_ The number of shares owned by the payee. */ function _addPayee(address account, uint256 shares_) private { require(account != address(0), "PaymentSplitter: account is the zero address"); require(shares_ > 0, "PaymentSplitter: shares are 0"); require(_shares[account] == 0, "PaymentSplitter: account already has shares"); _payees.push(account); _shares[account] = shares_; _totalShares = _totalShares + shares_; emit PayeeAdded(account, shares_); } }
/** * @title PaymentSplitter * @dev This contract allows to split Ether payments among a group of accounts. The sender does not need to be aware * that the Ether will be split in this way, since it is handled transparently by the contract. * * The split can be in equal parts or in any other arbitrary proportion. The way this is specified is by assigning each * account to a number of shares. Of all the Ether that this contract receives, each account will then be able to claim * an amount proportional to the percentage of total shares they were assigned. * * `PaymentSplitter` follows a _pull payment_ model. This means that payments are not automatically forwarded to the * accounts but kept in this contract, and the actual transfer is triggered as a separate step by calling the {release} * function. * * NOTE: This contract assumes that ERC20 tokens will behave similarly to native tokens (Ether). Rebasing tokens, and * tokens that apply fees during transfers, are likely to not be supported as expected. If in doubt, we encourage you * to run tests before sending real value to this contract. */
NatSpecMultiLine
totalShares
function totalShares() public view returns (uint256) { return _totalShares; }
/** * @dev Getter for the total shares held by payees. */
NatSpecMultiLine
v0.8.7+commit.e28d00a7
MIT
ipfs://414d9951eb094e9f3eecc45ff7dcf1c7de317858d1ad8616b1355e70b4b69e2c
{ "func_code_index": [ 2214, 2310 ] }
58,671
MegaMilionsGangstarApes
MegaMilionsGangstarApes.sol
0x3af32fd45224c502469af10e8fff285c18a978bc
Solidity
PaymentSplitter
contract PaymentSplitter is Context { event PayeeAdded(address account, uint256 shares); event PaymentReleased(address to, uint256 amount); event ERC20PaymentReleased(IERC20 indexed token, address to, uint256 amount); event PaymentReceived(address from, uint256 amount); event Warning(string message); uint256 private _totalShares = 50000; uint256 private _totalReleased; mapping(address => uint256) private _shares; mapping(address => uint256) private _released; address[] private _payees; mapping(IERC20 => uint256) private _erc20TotalReleased; mapping(IERC20 => mapping(address => uint256)) private _erc20Released; /** * @dev Creates an instance of `PaymentSplitter` where each account in `payees` is assigned the number of shares at * the matching position in the `shares` array. * * All addresses in `payees` must be non-zero. Both arrays must have the same non-zero length, and there must be no * duplicates in `payees`. */ constructor(address[] memory payees, uint256[] memory shares_) payable { require(payees.length == shares_.length, "PaymentSplitter: payees and shares length mismatch"); require(payees.length > 0, "PaymentSplitter: no payees"); for (uint256 i = 0; i < payees.length; i++) { _addPayee(payees[i], shares_[i]); } } /** * @dev The Ether received will be logged with {PaymentReceived} events. Note that these events are not fully * reliable: it's possible for a contract to receive Ether without triggering this function. This only affects the * reliability of the events, and not the actual splitting of Ether. * * To learn more about this see the Solidity documentation for * https://solidity.readthedocs.io/en/latest/contracts.html#fallback-function[fallback * functions]. */ receive() external payable virtual { emit PaymentReceived(_msgSender(), msg.value); } function addToReleased(uint256 amount) internal { _totalReleased += amount; } /** * @dev Getter for the total shares held by payees. */ function totalShares() public view returns (uint256) { return _totalShares; } /** * @dev Getter for the total amount of Ether already released. */ function totalReleased() public view returns (uint256) { return _totalReleased; } /** * @dev Getter for the total amount of `token` already released. `token` should be the address of an IERC20 * contract. */ function totalReleased(IERC20 token) public view returns (uint256) { return _erc20TotalReleased[token]; } /** * @dev Getter for the amount of shares held by an account. */ function shares(address account) public view returns (uint256) { return _shares[account]; } /** * @dev Getter for the amount of Ether already released to a payee. */ function released(address account) public view returns (uint256) { return _released[account]; } /** * @dev Getter for the amount of `token` tokens already released to a payee. `token` should be the address of an * IERC20 contract. */ function released(IERC20 token, address account) public view returns (uint256) { return _erc20Released[token][account]; } /** * @dev Getter for the address of the payee number `index`. */ function payee(uint256 index) public view returns (address) { return _payees[index]; } /** * @dev Triggers a transfer to `account` of the amount of Ether they are owed, according to their percentage of the * total shares and their previous withdrawals. */ function release(address payable account) public virtual { require(_shares[account] > 0, "PaymentSplitter: account has no shares"); uint256 totalReceived = address(this).balance + totalReleased(); uint256 payment = _pendingPayment(account, totalReceived, released(account)); if (payment != 0) { _released[account] += payment; _totalReleased += payment; Address.sendValue(account, payment); emit PaymentReleased(account, payment); } else { emit Warning("PaymentSplitter: account is not due payment"); } } /** * @dev Triggers a transfer to `account` of the amount of `token` tokens they are owed, according to their * percentage of the total shares and their previous withdrawals. `token` must be the address of an IERC20 * contract. */ function release(IERC20 token, address account) public virtual { require(_shares[account] > 0, "PaymentSplitter: account has no shares"); uint256 totalReceived = token.balanceOf(address(this)) + totalReleased(token); uint256 payment = _pendingPayment(account, totalReceived, released(token, account)); if (payment != 0) { _erc20Released[token][account] += payment; _erc20TotalReleased[token] += payment; SafeERC20.safeTransfer(token, account, payment); emit ERC20PaymentReleased(token, account, payment); } else { emit Warning("PaymentSplitter: account is not due payment"); } } /** * @dev internal logic for computing the pending payment of an `account` given the token historical balances and * already released amounts. */ function _pendingPayment( address account, uint256 totalReceived, uint256 alreadyReleased ) private view returns (uint256) { return (totalReceived * _shares[account]) / _totalShares - alreadyReleased; } /** * @dev Add a new payee to the contract. * @param account The address of the payee to add. * @param shares_ The number of shares owned by the payee. */ function _addPayee(address account, uint256 shares_) private { require(account != address(0), "PaymentSplitter: account is the zero address"); require(shares_ > 0, "PaymentSplitter: shares are 0"); require(_shares[account] == 0, "PaymentSplitter: account already has shares"); _payees.push(account); _shares[account] = shares_; _totalShares = _totalShares + shares_; emit PayeeAdded(account, shares_); } }
/** * @title PaymentSplitter * @dev This contract allows to split Ether payments among a group of accounts. The sender does not need to be aware * that the Ether will be split in this way, since it is handled transparently by the contract. * * The split can be in equal parts or in any other arbitrary proportion. The way this is specified is by assigning each * account to a number of shares. Of all the Ether that this contract receives, each account will then be able to claim * an amount proportional to the percentage of total shares they were assigned. * * `PaymentSplitter` follows a _pull payment_ model. This means that payments are not automatically forwarded to the * accounts but kept in this contract, and the actual transfer is triggered as a separate step by calling the {release} * function. * * NOTE: This contract assumes that ERC20 tokens will behave similarly to native tokens (Ether). Rebasing tokens, and * tokens that apply fees during transfers, are likely to not be supported as expected. If in doubt, we encourage you * to run tests before sending real value to this contract. */
NatSpecMultiLine
totalReleased
function totalReleased() public view returns (uint256) { return _totalReleased; }
/** * @dev Getter for the total amount of Ether already released. */
NatSpecMultiLine
v0.8.7+commit.e28d00a7
MIT
ipfs://414d9951eb094e9f3eecc45ff7dcf1c7de317858d1ad8616b1355e70b4b69e2c
{ "func_code_index": [ 2399, 2499 ] }
58,672
MegaMilionsGangstarApes
MegaMilionsGangstarApes.sol
0x3af32fd45224c502469af10e8fff285c18a978bc
Solidity
PaymentSplitter
contract PaymentSplitter is Context { event PayeeAdded(address account, uint256 shares); event PaymentReleased(address to, uint256 amount); event ERC20PaymentReleased(IERC20 indexed token, address to, uint256 amount); event PaymentReceived(address from, uint256 amount); event Warning(string message); uint256 private _totalShares = 50000; uint256 private _totalReleased; mapping(address => uint256) private _shares; mapping(address => uint256) private _released; address[] private _payees; mapping(IERC20 => uint256) private _erc20TotalReleased; mapping(IERC20 => mapping(address => uint256)) private _erc20Released; /** * @dev Creates an instance of `PaymentSplitter` where each account in `payees` is assigned the number of shares at * the matching position in the `shares` array. * * All addresses in `payees` must be non-zero. Both arrays must have the same non-zero length, and there must be no * duplicates in `payees`. */ constructor(address[] memory payees, uint256[] memory shares_) payable { require(payees.length == shares_.length, "PaymentSplitter: payees and shares length mismatch"); require(payees.length > 0, "PaymentSplitter: no payees"); for (uint256 i = 0; i < payees.length; i++) { _addPayee(payees[i], shares_[i]); } } /** * @dev The Ether received will be logged with {PaymentReceived} events. Note that these events are not fully * reliable: it's possible for a contract to receive Ether without triggering this function. This only affects the * reliability of the events, and not the actual splitting of Ether. * * To learn more about this see the Solidity documentation for * https://solidity.readthedocs.io/en/latest/contracts.html#fallback-function[fallback * functions]. */ receive() external payable virtual { emit PaymentReceived(_msgSender(), msg.value); } function addToReleased(uint256 amount) internal { _totalReleased += amount; } /** * @dev Getter for the total shares held by payees. */ function totalShares() public view returns (uint256) { return _totalShares; } /** * @dev Getter for the total amount of Ether already released. */ function totalReleased() public view returns (uint256) { return _totalReleased; } /** * @dev Getter for the total amount of `token` already released. `token` should be the address of an IERC20 * contract. */ function totalReleased(IERC20 token) public view returns (uint256) { return _erc20TotalReleased[token]; } /** * @dev Getter for the amount of shares held by an account. */ function shares(address account) public view returns (uint256) { return _shares[account]; } /** * @dev Getter for the amount of Ether already released to a payee. */ function released(address account) public view returns (uint256) { return _released[account]; } /** * @dev Getter for the amount of `token` tokens already released to a payee. `token` should be the address of an * IERC20 contract. */ function released(IERC20 token, address account) public view returns (uint256) { return _erc20Released[token][account]; } /** * @dev Getter for the address of the payee number `index`. */ function payee(uint256 index) public view returns (address) { return _payees[index]; } /** * @dev Triggers a transfer to `account` of the amount of Ether they are owed, according to their percentage of the * total shares and their previous withdrawals. */ function release(address payable account) public virtual { require(_shares[account] > 0, "PaymentSplitter: account has no shares"); uint256 totalReceived = address(this).balance + totalReleased(); uint256 payment = _pendingPayment(account, totalReceived, released(account)); if (payment != 0) { _released[account] += payment; _totalReleased += payment; Address.sendValue(account, payment); emit PaymentReleased(account, payment); } else { emit Warning("PaymentSplitter: account is not due payment"); } } /** * @dev Triggers a transfer to `account` of the amount of `token` tokens they are owed, according to their * percentage of the total shares and their previous withdrawals. `token` must be the address of an IERC20 * contract. */ function release(IERC20 token, address account) public virtual { require(_shares[account] > 0, "PaymentSplitter: account has no shares"); uint256 totalReceived = token.balanceOf(address(this)) + totalReleased(token); uint256 payment = _pendingPayment(account, totalReceived, released(token, account)); if (payment != 0) { _erc20Released[token][account] += payment; _erc20TotalReleased[token] += payment; SafeERC20.safeTransfer(token, account, payment); emit ERC20PaymentReleased(token, account, payment); } else { emit Warning("PaymentSplitter: account is not due payment"); } } /** * @dev internal logic for computing the pending payment of an `account` given the token historical balances and * already released amounts. */ function _pendingPayment( address account, uint256 totalReceived, uint256 alreadyReleased ) private view returns (uint256) { return (totalReceived * _shares[account]) / _totalShares - alreadyReleased; } /** * @dev Add a new payee to the contract. * @param account The address of the payee to add. * @param shares_ The number of shares owned by the payee. */ function _addPayee(address account, uint256 shares_) private { require(account != address(0), "PaymentSplitter: account is the zero address"); require(shares_ > 0, "PaymentSplitter: shares are 0"); require(_shares[account] == 0, "PaymentSplitter: account already has shares"); _payees.push(account); _shares[account] = shares_; _totalShares = _totalShares + shares_; emit PayeeAdded(account, shares_); } }
/** * @title PaymentSplitter * @dev This contract allows to split Ether payments among a group of accounts. The sender does not need to be aware * that the Ether will be split in this way, since it is handled transparently by the contract. * * The split can be in equal parts or in any other arbitrary proportion. The way this is specified is by assigning each * account to a number of shares. Of all the Ether that this contract receives, each account will then be able to claim * an amount proportional to the percentage of total shares they were assigned. * * `PaymentSplitter` follows a _pull payment_ model. This means that payments are not automatically forwarded to the * accounts but kept in this contract, and the actual transfer is triggered as a separate step by calling the {release} * function. * * NOTE: This contract assumes that ERC20 tokens will behave similarly to native tokens (Ether). Rebasing tokens, and * tokens that apply fees during transfers, are likely to not be supported as expected. If in doubt, we encourage you * to run tests before sending real value to this contract. */
NatSpecMultiLine
totalReleased
function totalReleased(IERC20 token) public view returns (uint256) { return _erc20TotalReleased[token]; }
/** * @dev Getter for the total amount of `token` already released. `token` should be the address of an IERC20 * contract. */
NatSpecMultiLine
v0.8.7+commit.e28d00a7
MIT
ipfs://414d9951eb094e9f3eecc45ff7dcf1c7de317858d1ad8616b1355e70b4b69e2c
{ "func_code_index": [ 2651, 2775 ] }
58,673
MegaMilionsGangstarApes
MegaMilionsGangstarApes.sol
0x3af32fd45224c502469af10e8fff285c18a978bc
Solidity
PaymentSplitter
contract PaymentSplitter is Context { event PayeeAdded(address account, uint256 shares); event PaymentReleased(address to, uint256 amount); event ERC20PaymentReleased(IERC20 indexed token, address to, uint256 amount); event PaymentReceived(address from, uint256 amount); event Warning(string message); uint256 private _totalShares = 50000; uint256 private _totalReleased; mapping(address => uint256) private _shares; mapping(address => uint256) private _released; address[] private _payees; mapping(IERC20 => uint256) private _erc20TotalReleased; mapping(IERC20 => mapping(address => uint256)) private _erc20Released; /** * @dev Creates an instance of `PaymentSplitter` where each account in `payees` is assigned the number of shares at * the matching position in the `shares` array. * * All addresses in `payees` must be non-zero. Both arrays must have the same non-zero length, and there must be no * duplicates in `payees`. */ constructor(address[] memory payees, uint256[] memory shares_) payable { require(payees.length == shares_.length, "PaymentSplitter: payees and shares length mismatch"); require(payees.length > 0, "PaymentSplitter: no payees"); for (uint256 i = 0; i < payees.length; i++) { _addPayee(payees[i], shares_[i]); } } /** * @dev The Ether received will be logged with {PaymentReceived} events. Note that these events are not fully * reliable: it's possible for a contract to receive Ether without triggering this function. This only affects the * reliability of the events, and not the actual splitting of Ether. * * To learn more about this see the Solidity documentation for * https://solidity.readthedocs.io/en/latest/contracts.html#fallback-function[fallback * functions]. */ receive() external payable virtual { emit PaymentReceived(_msgSender(), msg.value); } function addToReleased(uint256 amount) internal { _totalReleased += amount; } /** * @dev Getter for the total shares held by payees. */ function totalShares() public view returns (uint256) { return _totalShares; } /** * @dev Getter for the total amount of Ether already released. */ function totalReleased() public view returns (uint256) { return _totalReleased; } /** * @dev Getter for the total amount of `token` already released. `token` should be the address of an IERC20 * contract. */ function totalReleased(IERC20 token) public view returns (uint256) { return _erc20TotalReleased[token]; } /** * @dev Getter for the amount of shares held by an account. */ function shares(address account) public view returns (uint256) { return _shares[account]; } /** * @dev Getter for the amount of Ether already released to a payee. */ function released(address account) public view returns (uint256) { return _released[account]; } /** * @dev Getter for the amount of `token` tokens already released to a payee. `token` should be the address of an * IERC20 contract. */ function released(IERC20 token, address account) public view returns (uint256) { return _erc20Released[token][account]; } /** * @dev Getter for the address of the payee number `index`. */ function payee(uint256 index) public view returns (address) { return _payees[index]; } /** * @dev Triggers a transfer to `account` of the amount of Ether they are owed, according to their percentage of the * total shares and their previous withdrawals. */ function release(address payable account) public virtual { require(_shares[account] > 0, "PaymentSplitter: account has no shares"); uint256 totalReceived = address(this).balance + totalReleased(); uint256 payment = _pendingPayment(account, totalReceived, released(account)); if (payment != 0) { _released[account] += payment; _totalReleased += payment; Address.sendValue(account, payment); emit PaymentReleased(account, payment); } else { emit Warning("PaymentSplitter: account is not due payment"); } } /** * @dev Triggers a transfer to `account` of the amount of `token` tokens they are owed, according to their * percentage of the total shares and their previous withdrawals. `token` must be the address of an IERC20 * contract. */ function release(IERC20 token, address account) public virtual { require(_shares[account] > 0, "PaymentSplitter: account has no shares"); uint256 totalReceived = token.balanceOf(address(this)) + totalReleased(token); uint256 payment = _pendingPayment(account, totalReceived, released(token, account)); if (payment != 0) { _erc20Released[token][account] += payment; _erc20TotalReleased[token] += payment; SafeERC20.safeTransfer(token, account, payment); emit ERC20PaymentReleased(token, account, payment); } else { emit Warning("PaymentSplitter: account is not due payment"); } } /** * @dev internal logic for computing the pending payment of an `account` given the token historical balances and * already released amounts. */ function _pendingPayment( address account, uint256 totalReceived, uint256 alreadyReleased ) private view returns (uint256) { return (totalReceived * _shares[account]) / _totalShares - alreadyReleased; } /** * @dev Add a new payee to the contract. * @param account The address of the payee to add. * @param shares_ The number of shares owned by the payee. */ function _addPayee(address account, uint256 shares_) private { require(account != address(0), "PaymentSplitter: account is the zero address"); require(shares_ > 0, "PaymentSplitter: shares are 0"); require(_shares[account] == 0, "PaymentSplitter: account already has shares"); _payees.push(account); _shares[account] = shares_; _totalShares = _totalShares + shares_; emit PayeeAdded(account, shares_); } }
/** * @title PaymentSplitter * @dev This contract allows to split Ether payments among a group of accounts. The sender does not need to be aware * that the Ether will be split in this way, since it is handled transparently by the contract. * * The split can be in equal parts or in any other arbitrary proportion. The way this is specified is by assigning each * account to a number of shares. Of all the Ether that this contract receives, each account will then be able to claim * an amount proportional to the percentage of total shares they were assigned. * * `PaymentSplitter` follows a _pull payment_ model. This means that payments are not automatically forwarded to the * accounts but kept in this contract, and the actual transfer is triggered as a separate step by calling the {release} * function. * * NOTE: This contract assumes that ERC20 tokens will behave similarly to native tokens (Ether). Rebasing tokens, and * tokens that apply fees during transfers, are likely to not be supported as expected. If in doubt, we encourage you * to run tests before sending real value to this contract. */
NatSpecMultiLine
shares
function shares(address account) public view returns (uint256) { return _shares[account]; }
/** * @dev Getter for the amount of shares held by an account. */
NatSpecMultiLine
v0.8.7+commit.e28d00a7
MIT
ipfs://414d9951eb094e9f3eecc45ff7dcf1c7de317858d1ad8616b1355e70b4b69e2c
{ "func_code_index": [ 2861, 2971 ] }
58,674
MegaMilionsGangstarApes
MegaMilionsGangstarApes.sol
0x3af32fd45224c502469af10e8fff285c18a978bc
Solidity
PaymentSplitter
contract PaymentSplitter is Context { event PayeeAdded(address account, uint256 shares); event PaymentReleased(address to, uint256 amount); event ERC20PaymentReleased(IERC20 indexed token, address to, uint256 amount); event PaymentReceived(address from, uint256 amount); event Warning(string message); uint256 private _totalShares = 50000; uint256 private _totalReleased; mapping(address => uint256) private _shares; mapping(address => uint256) private _released; address[] private _payees; mapping(IERC20 => uint256) private _erc20TotalReleased; mapping(IERC20 => mapping(address => uint256)) private _erc20Released; /** * @dev Creates an instance of `PaymentSplitter` where each account in `payees` is assigned the number of shares at * the matching position in the `shares` array. * * All addresses in `payees` must be non-zero. Both arrays must have the same non-zero length, and there must be no * duplicates in `payees`. */ constructor(address[] memory payees, uint256[] memory shares_) payable { require(payees.length == shares_.length, "PaymentSplitter: payees and shares length mismatch"); require(payees.length > 0, "PaymentSplitter: no payees"); for (uint256 i = 0; i < payees.length; i++) { _addPayee(payees[i], shares_[i]); } } /** * @dev The Ether received will be logged with {PaymentReceived} events. Note that these events are not fully * reliable: it's possible for a contract to receive Ether without triggering this function. This only affects the * reliability of the events, and not the actual splitting of Ether. * * To learn more about this see the Solidity documentation for * https://solidity.readthedocs.io/en/latest/contracts.html#fallback-function[fallback * functions]. */ receive() external payable virtual { emit PaymentReceived(_msgSender(), msg.value); } function addToReleased(uint256 amount) internal { _totalReleased += amount; } /** * @dev Getter for the total shares held by payees. */ function totalShares() public view returns (uint256) { return _totalShares; } /** * @dev Getter for the total amount of Ether already released. */ function totalReleased() public view returns (uint256) { return _totalReleased; } /** * @dev Getter for the total amount of `token` already released. `token` should be the address of an IERC20 * contract. */ function totalReleased(IERC20 token) public view returns (uint256) { return _erc20TotalReleased[token]; } /** * @dev Getter for the amount of shares held by an account. */ function shares(address account) public view returns (uint256) { return _shares[account]; } /** * @dev Getter for the amount of Ether already released to a payee. */ function released(address account) public view returns (uint256) { return _released[account]; } /** * @dev Getter for the amount of `token` tokens already released to a payee. `token` should be the address of an * IERC20 contract. */ function released(IERC20 token, address account) public view returns (uint256) { return _erc20Released[token][account]; } /** * @dev Getter for the address of the payee number `index`. */ function payee(uint256 index) public view returns (address) { return _payees[index]; } /** * @dev Triggers a transfer to `account` of the amount of Ether they are owed, according to their percentage of the * total shares and their previous withdrawals. */ function release(address payable account) public virtual { require(_shares[account] > 0, "PaymentSplitter: account has no shares"); uint256 totalReceived = address(this).balance + totalReleased(); uint256 payment = _pendingPayment(account, totalReceived, released(account)); if (payment != 0) { _released[account] += payment; _totalReleased += payment; Address.sendValue(account, payment); emit PaymentReleased(account, payment); } else { emit Warning("PaymentSplitter: account is not due payment"); } } /** * @dev Triggers a transfer to `account` of the amount of `token` tokens they are owed, according to their * percentage of the total shares and their previous withdrawals. `token` must be the address of an IERC20 * contract. */ function release(IERC20 token, address account) public virtual { require(_shares[account] > 0, "PaymentSplitter: account has no shares"); uint256 totalReceived = token.balanceOf(address(this)) + totalReleased(token); uint256 payment = _pendingPayment(account, totalReceived, released(token, account)); if (payment != 0) { _erc20Released[token][account] += payment; _erc20TotalReleased[token] += payment; SafeERC20.safeTransfer(token, account, payment); emit ERC20PaymentReleased(token, account, payment); } else { emit Warning("PaymentSplitter: account is not due payment"); } } /** * @dev internal logic for computing the pending payment of an `account` given the token historical balances and * already released amounts. */ function _pendingPayment( address account, uint256 totalReceived, uint256 alreadyReleased ) private view returns (uint256) { return (totalReceived * _shares[account]) / _totalShares - alreadyReleased; } /** * @dev Add a new payee to the contract. * @param account The address of the payee to add. * @param shares_ The number of shares owned by the payee. */ function _addPayee(address account, uint256 shares_) private { require(account != address(0), "PaymentSplitter: account is the zero address"); require(shares_ > 0, "PaymentSplitter: shares are 0"); require(_shares[account] == 0, "PaymentSplitter: account already has shares"); _payees.push(account); _shares[account] = shares_; _totalShares = _totalShares + shares_; emit PayeeAdded(account, shares_); } }
/** * @title PaymentSplitter * @dev This contract allows to split Ether payments among a group of accounts. The sender does not need to be aware * that the Ether will be split in this way, since it is handled transparently by the contract. * * The split can be in equal parts or in any other arbitrary proportion. The way this is specified is by assigning each * account to a number of shares. Of all the Ether that this contract receives, each account will then be able to claim * an amount proportional to the percentage of total shares they were assigned. * * `PaymentSplitter` follows a _pull payment_ model. This means that payments are not automatically forwarded to the * accounts but kept in this contract, and the actual transfer is triggered as a separate step by calling the {release} * function. * * NOTE: This contract assumes that ERC20 tokens will behave similarly to native tokens (Ether). Rebasing tokens, and * tokens that apply fees during transfers, are likely to not be supported as expected. If in doubt, we encourage you * to run tests before sending real value to this contract. */
NatSpecMultiLine
released
function released(address account) public view returns (uint256) { return _released[account]; }
/** * @dev Getter for the amount of Ether already released to a payee. */
NatSpecMultiLine
v0.8.7+commit.e28d00a7
MIT
ipfs://414d9951eb094e9f3eecc45ff7dcf1c7de317858d1ad8616b1355e70b4b69e2c
{ "func_code_index": [ 3065, 3179 ] }
58,675
MegaMilionsGangstarApes
MegaMilionsGangstarApes.sol
0x3af32fd45224c502469af10e8fff285c18a978bc
Solidity
PaymentSplitter
contract PaymentSplitter is Context { event PayeeAdded(address account, uint256 shares); event PaymentReleased(address to, uint256 amount); event ERC20PaymentReleased(IERC20 indexed token, address to, uint256 amount); event PaymentReceived(address from, uint256 amount); event Warning(string message); uint256 private _totalShares = 50000; uint256 private _totalReleased; mapping(address => uint256) private _shares; mapping(address => uint256) private _released; address[] private _payees; mapping(IERC20 => uint256) private _erc20TotalReleased; mapping(IERC20 => mapping(address => uint256)) private _erc20Released; /** * @dev Creates an instance of `PaymentSplitter` where each account in `payees` is assigned the number of shares at * the matching position in the `shares` array. * * All addresses in `payees` must be non-zero. Both arrays must have the same non-zero length, and there must be no * duplicates in `payees`. */ constructor(address[] memory payees, uint256[] memory shares_) payable { require(payees.length == shares_.length, "PaymentSplitter: payees and shares length mismatch"); require(payees.length > 0, "PaymentSplitter: no payees"); for (uint256 i = 0; i < payees.length; i++) { _addPayee(payees[i], shares_[i]); } } /** * @dev The Ether received will be logged with {PaymentReceived} events. Note that these events are not fully * reliable: it's possible for a contract to receive Ether without triggering this function. This only affects the * reliability of the events, and not the actual splitting of Ether. * * To learn more about this see the Solidity documentation for * https://solidity.readthedocs.io/en/latest/contracts.html#fallback-function[fallback * functions]. */ receive() external payable virtual { emit PaymentReceived(_msgSender(), msg.value); } function addToReleased(uint256 amount) internal { _totalReleased += amount; } /** * @dev Getter for the total shares held by payees. */ function totalShares() public view returns (uint256) { return _totalShares; } /** * @dev Getter for the total amount of Ether already released. */ function totalReleased() public view returns (uint256) { return _totalReleased; } /** * @dev Getter for the total amount of `token` already released. `token` should be the address of an IERC20 * contract. */ function totalReleased(IERC20 token) public view returns (uint256) { return _erc20TotalReleased[token]; } /** * @dev Getter for the amount of shares held by an account. */ function shares(address account) public view returns (uint256) { return _shares[account]; } /** * @dev Getter for the amount of Ether already released to a payee. */ function released(address account) public view returns (uint256) { return _released[account]; } /** * @dev Getter for the amount of `token` tokens already released to a payee. `token` should be the address of an * IERC20 contract. */ function released(IERC20 token, address account) public view returns (uint256) { return _erc20Released[token][account]; } /** * @dev Getter for the address of the payee number `index`. */ function payee(uint256 index) public view returns (address) { return _payees[index]; } /** * @dev Triggers a transfer to `account` of the amount of Ether they are owed, according to their percentage of the * total shares and their previous withdrawals. */ function release(address payable account) public virtual { require(_shares[account] > 0, "PaymentSplitter: account has no shares"); uint256 totalReceived = address(this).balance + totalReleased(); uint256 payment = _pendingPayment(account, totalReceived, released(account)); if (payment != 0) { _released[account] += payment; _totalReleased += payment; Address.sendValue(account, payment); emit PaymentReleased(account, payment); } else { emit Warning("PaymentSplitter: account is not due payment"); } } /** * @dev Triggers a transfer to `account` of the amount of `token` tokens they are owed, according to their * percentage of the total shares and their previous withdrawals. `token` must be the address of an IERC20 * contract. */ function release(IERC20 token, address account) public virtual { require(_shares[account] > 0, "PaymentSplitter: account has no shares"); uint256 totalReceived = token.balanceOf(address(this)) + totalReleased(token); uint256 payment = _pendingPayment(account, totalReceived, released(token, account)); if (payment != 0) { _erc20Released[token][account] += payment; _erc20TotalReleased[token] += payment; SafeERC20.safeTransfer(token, account, payment); emit ERC20PaymentReleased(token, account, payment); } else { emit Warning("PaymentSplitter: account is not due payment"); } } /** * @dev internal logic for computing the pending payment of an `account` given the token historical balances and * already released amounts. */ function _pendingPayment( address account, uint256 totalReceived, uint256 alreadyReleased ) private view returns (uint256) { return (totalReceived * _shares[account]) / _totalShares - alreadyReleased; } /** * @dev Add a new payee to the contract. * @param account The address of the payee to add. * @param shares_ The number of shares owned by the payee. */ function _addPayee(address account, uint256 shares_) private { require(account != address(0), "PaymentSplitter: account is the zero address"); require(shares_ > 0, "PaymentSplitter: shares are 0"); require(_shares[account] == 0, "PaymentSplitter: account already has shares"); _payees.push(account); _shares[account] = shares_; _totalShares = _totalShares + shares_; emit PayeeAdded(account, shares_); } }
/** * @title PaymentSplitter * @dev This contract allows to split Ether payments among a group of accounts. The sender does not need to be aware * that the Ether will be split in this way, since it is handled transparently by the contract. * * The split can be in equal parts or in any other arbitrary proportion. The way this is specified is by assigning each * account to a number of shares. Of all the Ether that this contract receives, each account will then be able to claim * an amount proportional to the percentage of total shares they were assigned. * * `PaymentSplitter` follows a _pull payment_ model. This means that payments are not automatically forwarded to the * accounts but kept in this contract, and the actual transfer is triggered as a separate step by calling the {release} * function. * * NOTE: This contract assumes that ERC20 tokens will behave similarly to native tokens (Ether). Rebasing tokens, and * tokens that apply fees during transfers, are likely to not be supported as expected. If in doubt, we encourage you * to run tests before sending real value to this contract. */
NatSpecMultiLine
released
function released(IERC20 token, address account) public view returns (uint256) { return _erc20Released[token][account]; }
/** * @dev Getter for the amount of `token` tokens already released to a payee. `token` should be the address of an * IERC20 contract. */
NatSpecMultiLine
v0.8.7+commit.e28d00a7
MIT
ipfs://414d9951eb094e9f3eecc45ff7dcf1c7de317858d1ad8616b1355e70b4b69e2c
{ "func_code_index": [ 3343, 3483 ] }
58,676
MegaMilionsGangstarApes
MegaMilionsGangstarApes.sol
0x3af32fd45224c502469af10e8fff285c18a978bc
Solidity
PaymentSplitter
contract PaymentSplitter is Context { event PayeeAdded(address account, uint256 shares); event PaymentReleased(address to, uint256 amount); event ERC20PaymentReleased(IERC20 indexed token, address to, uint256 amount); event PaymentReceived(address from, uint256 amount); event Warning(string message); uint256 private _totalShares = 50000; uint256 private _totalReleased; mapping(address => uint256) private _shares; mapping(address => uint256) private _released; address[] private _payees; mapping(IERC20 => uint256) private _erc20TotalReleased; mapping(IERC20 => mapping(address => uint256)) private _erc20Released; /** * @dev Creates an instance of `PaymentSplitter` where each account in `payees` is assigned the number of shares at * the matching position in the `shares` array. * * All addresses in `payees` must be non-zero. Both arrays must have the same non-zero length, and there must be no * duplicates in `payees`. */ constructor(address[] memory payees, uint256[] memory shares_) payable { require(payees.length == shares_.length, "PaymentSplitter: payees and shares length mismatch"); require(payees.length > 0, "PaymentSplitter: no payees"); for (uint256 i = 0; i < payees.length; i++) { _addPayee(payees[i], shares_[i]); } } /** * @dev The Ether received will be logged with {PaymentReceived} events. Note that these events are not fully * reliable: it's possible for a contract to receive Ether without triggering this function. This only affects the * reliability of the events, and not the actual splitting of Ether. * * To learn more about this see the Solidity documentation for * https://solidity.readthedocs.io/en/latest/contracts.html#fallback-function[fallback * functions]. */ receive() external payable virtual { emit PaymentReceived(_msgSender(), msg.value); } function addToReleased(uint256 amount) internal { _totalReleased += amount; } /** * @dev Getter for the total shares held by payees. */ function totalShares() public view returns (uint256) { return _totalShares; } /** * @dev Getter for the total amount of Ether already released. */ function totalReleased() public view returns (uint256) { return _totalReleased; } /** * @dev Getter for the total amount of `token` already released. `token` should be the address of an IERC20 * contract. */ function totalReleased(IERC20 token) public view returns (uint256) { return _erc20TotalReleased[token]; } /** * @dev Getter for the amount of shares held by an account. */ function shares(address account) public view returns (uint256) { return _shares[account]; } /** * @dev Getter for the amount of Ether already released to a payee. */ function released(address account) public view returns (uint256) { return _released[account]; } /** * @dev Getter for the amount of `token` tokens already released to a payee. `token` should be the address of an * IERC20 contract. */ function released(IERC20 token, address account) public view returns (uint256) { return _erc20Released[token][account]; } /** * @dev Getter for the address of the payee number `index`. */ function payee(uint256 index) public view returns (address) { return _payees[index]; } /** * @dev Triggers a transfer to `account` of the amount of Ether they are owed, according to their percentage of the * total shares and their previous withdrawals. */ function release(address payable account) public virtual { require(_shares[account] > 0, "PaymentSplitter: account has no shares"); uint256 totalReceived = address(this).balance + totalReleased(); uint256 payment = _pendingPayment(account, totalReceived, released(account)); if (payment != 0) { _released[account] += payment; _totalReleased += payment; Address.sendValue(account, payment); emit PaymentReleased(account, payment); } else { emit Warning("PaymentSplitter: account is not due payment"); } } /** * @dev Triggers a transfer to `account` of the amount of `token` tokens they are owed, according to their * percentage of the total shares and their previous withdrawals. `token` must be the address of an IERC20 * contract. */ function release(IERC20 token, address account) public virtual { require(_shares[account] > 0, "PaymentSplitter: account has no shares"); uint256 totalReceived = token.balanceOf(address(this)) + totalReleased(token); uint256 payment = _pendingPayment(account, totalReceived, released(token, account)); if (payment != 0) { _erc20Released[token][account] += payment; _erc20TotalReleased[token] += payment; SafeERC20.safeTransfer(token, account, payment); emit ERC20PaymentReleased(token, account, payment); } else { emit Warning("PaymentSplitter: account is not due payment"); } } /** * @dev internal logic for computing the pending payment of an `account` given the token historical balances and * already released amounts. */ function _pendingPayment( address account, uint256 totalReceived, uint256 alreadyReleased ) private view returns (uint256) { return (totalReceived * _shares[account]) / _totalShares - alreadyReleased; } /** * @dev Add a new payee to the contract. * @param account The address of the payee to add. * @param shares_ The number of shares owned by the payee. */ function _addPayee(address account, uint256 shares_) private { require(account != address(0), "PaymentSplitter: account is the zero address"); require(shares_ > 0, "PaymentSplitter: shares are 0"); require(_shares[account] == 0, "PaymentSplitter: account already has shares"); _payees.push(account); _shares[account] = shares_; _totalShares = _totalShares + shares_; emit PayeeAdded(account, shares_); } }
/** * @title PaymentSplitter * @dev This contract allows to split Ether payments among a group of accounts. The sender does not need to be aware * that the Ether will be split in this way, since it is handled transparently by the contract. * * The split can be in equal parts or in any other arbitrary proportion. The way this is specified is by assigning each * account to a number of shares. Of all the Ether that this contract receives, each account will then be able to claim * an amount proportional to the percentage of total shares they were assigned. * * `PaymentSplitter` follows a _pull payment_ model. This means that payments are not automatically forwarded to the * accounts but kept in this contract, and the actual transfer is triggered as a separate step by calling the {release} * function. * * NOTE: This contract assumes that ERC20 tokens will behave similarly to native tokens (Ether). Rebasing tokens, and * tokens that apply fees during transfers, are likely to not be supported as expected. If in doubt, we encourage you * to run tests before sending real value to this contract. */
NatSpecMultiLine
payee
function payee(uint256 index) public view returns (address) { return _payees[index]; }
/** * @dev Getter for the address of the payee number `index`. */
NatSpecMultiLine
v0.8.7+commit.e28d00a7
MIT
ipfs://414d9951eb094e9f3eecc45ff7dcf1c7de317858d1ad8616b1355e70b4b69e2c
{ "func_code_index": [ 3569, 3674 ] }
58,677
MegaMilionsGangstarApes
MegaMilionsGangstarApes.sol
0x3af32fd45224c502469af10e8fff285c18a978bc
Solidity
PaymentSplitter
contract PaymentSplitter is Context { event PayeeAdded(address account, uint256 shares); event PaymentReleased(address to, uint256 amount); event ERC20PaymentReleased(IERC20 indexed token, address to, uint256 amount); event PaymentReceived(address from, uint256 amount); event Warning(string message); uint256 private _totalShares = 50000; uint256 private _totalReleased; mapping(address => uint256) private _shares; mapping(address => uint256) private _released; address[] private _payees; mapping(IERC20 => uint256) private _erc20TotalReleased; mapping(IERC20 => mapping(address => uint256)) private _erc20Released; /** * @dev Creates an instance of `PaymentSplitter` where each account in `payees` is assigned the number of shares at * the matching position in the `shares` array. * * All addresses in `payees` must be non-zero. Both arrays must have the same non-zero length, and there must be no * duplicates in `payees`. */ constructor(address[] memory payees, uint256[] memory shares_) payable { require(payees.length == shares_.length, "PaymentSplitter: payees and shares length mismatch"); require(payees.length > 0, "PaymentSplitter: no payees"); for (uint256 i = 0; i < payees.length; i++) { _addPayee(payees[i], shares_[i]); } } /** * @dev The Ether received will be logged with {PaymentReceived} events. Note that these events are not fully * reliable: it's possible for a contract to receive Ether without triggering this function. This only affects the * reliability of the events, and not the actual splitting of Ether. * * To learn more about this see the Solidity documentation for * https://solidity.readthedocs.io/en/latest/contracts.html#fallback-function[fallback * functions]. */ receive() external payable virtual { emit PaymentReceived(_msgSender(), msg.value); } function addToReleased(uint256 amount) internal { _totalReleased += amount; } /** * @dev Getter for the total shares held by payees. */ function totalShares() public view returns (uint256) { return _totalShares; } /** * @dev Getter for the total amount of Ether already released. */ function totalReleased() public view returns (uint256) { return _totalReleased; } /** * @dev Getter for the total amount of `token` already released. `token` should be the address of an IERC20 * contract. */ function totalReleased(IERC20 token) public view returns (uint256) { return _erc20TotalReleased[token]; } /** * @dev Getter for the amount of shares held by an account. */ function shares(address account) public view returns (uint256) { return _shares[account]; } /** * @dev Getter for the amount of Ether already released to a payee. */ function released(address account) public view returns (uint256) { return _released[account]; } /** * @dev Getter for the amount of `token` tokens already released to a payee. `token` should be the address of an * IERC20 contract. */ function released(IERC20 token, address account) public view returns (uint256) { return _erc20Released[token][account]; } /** * @dev Getter for the address of the payee number `index`. */ function payee(uint256 index) public view returns (address) { return _payees[index]; } /** * @dev Triggers a transfer to `account` of the amount of Ether they are owed, according to their percentage of the * total shares and their previous withdrawals. */ function release(address payable account) public virtual { require(_shares[account] > 0, "PaymentSplitter: account has no shares"); uint256 totalReceived = address(this).balance + totalReleased(); uint256 payment = _pendingPayment(account, totalReceived, released(account)); if (payment != 0) { _released[account] += payment; _totalReleased += payment; Address.sendValue(account, payment); emit PaymentReleased(account, payment); } else { emit Warning("PaymentSplitter: account is not due payment"); } } /** * @dev Triggers a transfer to `account` of the amount of `token` tokens they are owed, according to their * percentage of the total shares and their previous withdrawals. `token` must be the address of an IERC20 * contract. */ function release(IERC20 token, address account) public virtual { require(_shares[account] > 0, "PaymentSplitter: account has no shares"); uint256 totalReceived = token.balanceOf(address(this)) + totalReleased(token); uint256 payment = _pendingPayment(account, totalReceived, released(token, account)); if (payment != 0) { _erc20Released[token][account] += payment; _erc20TotalReleased[token] += payment; SafeERC20.safeTransfer(token, account, payment); emit ERC20PaymentReleased(token, account, payment); } else { emit Warning("PaymentSplitter: account is not due payment"); } } /** * @dev internal logic for computing the pending payment of an `account` given the token historical balances and * already released amounts. */ function _pendingPayment( address account, uint256 totalReceived, uint256 alreadyReleased ) private view returns (uint256) { return (totalReceived * _shares[account]) / _totalShares - alreadyReleased; } /** * @dev Add a new payee to the contract. * @param account The address of the payee to add. * @param shares_ The number of shares owned by the payee. */ function _addPayee(address account, uint256 shares_) private { require(account != address(0), "PaymentSplitter: account is the zero address"); require(shares_ > 0, "PaymentSplitter: shares are 0"); require(_shares[account] == 0, "PaymentSplitter: account already has shares"); _payees.push(account); _shares[account] = shares_; _totalShares = _totalShares + shares_; emit PayeeAdded(account, shares_); } }
/** * @title PaymentSplitter * @dev This contract allows to split Ether payments among a group of accounts. The sender does not need to be aware * that the Ether will be split in this way, since it is handled transparently by the contract. * * The split can be in equal parts or in any other arbitrary proportion. The way this is specified is by assigning each * account to a number of shares. Of all the Ether that this contract receives, each account will then be able to claim * an amount proportional to the percentage of total shares they were assigned. * * `PaymentSplitter` follows a _pull payment_ model. This means that payments are not automatically forwarded to the * accounts but kept in this contract, and the actual transfer is triggered as a separate step by calling the {release} * function. * * NOTE: This contract assumes that ERC20 tokens will behave similarly to native tokens (Ether). Rebasing tokens, and * tokens that apply fees during transfers, are likely to not be supported as expected. If in doubt, we encourage you * to run tests before sending real value to this contract. */
NatSpecMultiLine
release
function release(address payable account) public virtual { require(_shares[account] > 0, "PaymentSplitter: account has no shares"); uint256 totalReceived = address(this).balance + totalReleased(); uint256 payment = _pendingPayment(account, totalReceived, released(account)); if (payment != 0) { _released[account] += payment; _totalReleased += payment; Address.sendValue(account, payment); emit PaymentReleased(account, payment); } else { emit Warning("PaymentSplitter: account is not due payment"); } }
/** * @dev Triggers a transfer to `account` of the amount of Ether they are owed, according to their percentage of the * total shares and their previous withdrawals. */
NatSpecMultiLine
v0.8.7+commit.e28d00a7
MIT
ipfs://414d9951eb094e9f3eecc45ff7dcf1c7de317858d1ad8616b1355e70b4b69e2c
{ "func_code_index": [ 3869, 4507 ] }
58,678
MegaMilionsGangstarApes
MegaMilionsGangstarApes.sol
0x3af32fd45224c502469af10e8fff285c18a978bc
Solidity
PaymentSplitter
contract PaymentSplitter is Context { event PayeeAdded(address account, uint256 shares); event PaymentReleased(address to, uint256 amount); event ERC20PaymentReleased(IERC20 indexed token, address to, uint256 amount); event PaymentReceived(address from, uint256 amount); event Warning(string message); uint256 private _totalShares = 50000; uint256 private _totalReleased; mapping(address => uint256) private _shares; mapping(address => uint256) private _released; address[] private _payees; mapping(IERC20 => uint256) private _erc20TotalReleased; mapping(IERC20 => mapping(address => uint256)) private _erc20Released; /** * @dev Creates an instance of `PaymentSplitter` where each account in `payees` is assigned the number of shares at * the matching position in the `shares` array. * * All addresses in `payees` must be non-zero. Both arrays must have the same non-zero length, and there must be no * duplicates in `payees`. */ constructor(address[] memory payees, uint256[] memory shares_) payable { require(payees.length == shares_.length, "PaymentSplitter: payees and shares length mismatch"); require(payees.length > 0, "PaymentSplitter: no payees"); for (uint256 i = 0; i < payees.length; i++) { _addPayee(payees[i], shares_[i]); } } /** * @dev The Ether received will be logged with {PaymentReceived} events. Note that these events are not fully * reliable: it's possible for a contract to receive Ether without triggering this function. This only affects the * reliability of the events, and not the actual splitting of Ether. * * To learn more about this see the Solidity documentation for * https://solidity.readthedocs.io/en/latest/contracts.html#fallback-function[fallback * functions]. */ receive() external payable virtual { emit PaymentReceived(_msgSender(), msg.value); } function addToReleased(uint256 amount) internal { _totalReleased += amount; } /** * @dev Getter for the total shares held by payees. */ function totalShares() public view returns (uint256) { return _totalShares; } /** * @dev Getter for the total amount of Ether already released. */ function totalReleased() public view returns (uint256) { return _totalReleased; } /** * @dev Getter for the total amount of `token` already released. `token` should be the address of an IERC20 * contract. */ function totalReleased(IERC20 token) public view returns (uint256) { return _erc20TotalReleased[token]; } /** * @dev Getter for the amount of shares held by an account. */ function shares(address account) public view returns (uint256) { return _shares[account]; } /** * @dev Getter for the amount of Ether already released to a payee. */ function released(address account) public view returns (uint256) { return _released[account]; } /** * @dev Getter for the amount of `token` tokens already released to a payee. `token` should be the address of an * IERC20 contract. */ function released(IERC20 token, address account) public view returns (uint256) { return _erc20Released[token][account]; } /** * @dev Getter for the address of the payee number `index`. */ function payee(uint256 index) public view returns (address) { return _payees[index]; } /** * @dev Triggers a transfer to `account` of the amount of Ether they are owed, according to their percentage of the * total shares and their previous withdrawals. */ function release(address payable account) public virtual { require(_shares[account] > 0, "PaymentSplitter: account has no shares"); uint256 totalReceived = address(this).balance + totalReleased(); uint256 payment = _pendingPayment(account, totalReceived, released(account)); if (payment != 0) { _released[account] += payment; _totalReleased += payment; Address.sendValue(account, payment); emit PaymentReleased(account, payment); } else { emit Warning("PaymentSplitter: account is not due payment"); } } /** * @dev Triggers a transfer to `account` of the amount of `token` tokens they are owed, according to their * percentage of the total shares and their previous withdrawals. `token` must be the address of an IERC20 * contract. */ function release(IERC20 token, address account) public virtual { require(_shares[account] > 0, "PaymentSplitter: account has no shares"); uint256 totalReceived = token.balanceOf(address(this)) + totalReleased(token); uint256 payment = _pendingPayment(account, totalReceived, released(token, account)); if (payment != 0) { _erc20Released[token][account] += payment; _erc20TotalReleased[token] += payment; SafeERC20.safeTransfer(token, account, payment); emit ERC20PaymentReleased(token, account, payment); } else { emit Warning("PaymentSplitter: account is not due payment"); } } /** * @dev internal logic for computing the pending payment of an `account` given the token historical balances and * already released amounts. */ function _pendingPayment( address account, uint256 totalReceived, uint256 alreadyReleased ) private view returns (uint256) { return (totalReceived * _shares[account]) / _totalShares - alreadyReleased; } /** * @dev Add a new payee to the contract. * @param account The address of the payee to add. * @param shares_ The number of shares owned by the payee. */ function _addPayee(address account, uint256 shares_) private { require(account != address(0), "PaymentSplitter: account is the zero address"); require(shares_ > 0, "PaymentSplitter: shares are 0"); require(_shares[account] == 0, "PaymentSplitter: account already has shares"); _payees.push(account); _shares[account] = shares_; _totalShares = _totalShares + shares_; emit PayeeAdded(account, shares_); } }
/** * @title PaymentSplitter * @dev This contract allows to split Ether payments among a group of accounts. The sender does not need to be aware * that the Ether will be split in this way, since it is handled transparently by the contract. * * The split can be in equal parts or in any other arbitrary proportion. The way this is specified is by assigning each * account to a number of shares. Of all the Ether that this contract receives, each account will then be able to claim * an amount proportional to the percentage of total shares they were assigned. * * `PaymentSplitter` follows a _pull payment_ model. This means that payments are not automatically forwarded to the * accounts but kept in this contract, and the actual transfer is triggered as a separate step by calling the {release} * function. * * NOTE: This contract assumes that ERC20 tokens will behave similarly to native tokens (Ether). Rebasing tokens, and * tokens that apply fees during transfers, are likely to not be supported as expected. If in doubt, we encourage you * to run tests before sending real value to this contract. */
NatSpecMultiLine
release
function release(IERC20 token, address account) public virtual { require(_shares[account] > 0, "PaymentSplitter: account has no shares"); uint256 totalReceived = token.balanceOf(address(this)) + totalReleased(token); uint256 payment = _pendingPayment(account, totalReceived, released(token, account)); if (payment != 0) { _erc20Released[token][account] += payment; _erc20TotalReleased[token] += payment; SafeERC20.safeTransfer(token, account, payment); emit ERC20PaymentReleased(token, account, payment); } else { emit Warning("PaymentSplitter: account is not due payment"); } }
/** * @dev Triggers a transfer to `account` of the amount of `token` tokens they are owed, according to their * percentage of the total shares and their previous withdrawals. `token` must be the address of an IERC20 * contract. */
NatSpecMultiLine
v0.8.7+commit.e28d00a7
MIT
ipfs://414d9951eb094e9f3eecc45ff7dcf1c7de317858d1ad8616b1355e70b4b69e2c
{ "func_code_index": [ 4770, 5483 ] }
58,679
MegaMilionsGangstarApes
MegaMilionsGangstarApes.sol
0x3af32fd45224c502469af10e8fff285c18a978bc
Solidity
PaymentSplitter
contract PaymentSplitter is Context { event PayeeAdded(address account, uint256 shares); event PaymentReleased(address to, uint256 amount); event ERC20PaymentReleased(IERC20 indexed token, address to, uint256 amount); event PaymentReceived(address from, uint256 amount); event Warning(string message); uint256 private _totalShares = 50000; uint256 private _totalReleased; mapping(address => uint256) private _shares; mapping(address => uint256) private _released; address[] private _payees; mapping(IERC20 => uint256) private _erc20TotalReleased; mapping(IERC20 => mapping(address => uint256)) private _erc20Released; /** * @dev Creates an instance of `PaymentSplitter` where each account in `payees` is assigned the number of shares at * the matching position in the `shares` array. * * All addresses in `payees` must be non-zero. Both arrays must have the same non-zero length, and there must be no * duplicates in `payees`. */ constructor(address[] memory payees, uint256[] memory shares_) payable { require(payees.length == shares_.length, "PaymentSplitter: payees and shares length mismatch"); require(payees.length > 0, "PaymentSplitter: no payees"); for (uint256 i = 0; i < payees.length; i++) { _addPayee(payees[i], shares_[i]); } } /** * @dev The Ether received will be logged with {PaymentReceived} events. Note that these events are not fully * reliable: it's possible for a contract to receive Ether without triggering this function. This only affects the * reliability of the events, and not the actual splitting of Ether. * * To learn more about this see the Solidity documentation for * https://solidity.readthedocs.io/en/latest/contracts.html#fallback-function[fallback * functions]. */ receive() external payable virtual { emit PaymentReceived(_msgSender(), msg.value); } function addToReleased(uint256 amount) internal { _totalReleased += amount; } /** * @dev Getter for the total shares held by payees. */ function totalShares() public view returns (uint256) { return _totalShares; } /** * @dev Getter for the total amount of Ether already released. */ function totalReleased() public view returns (uint256) { return _totalReleased; } /** * @dev Getter for the total amount of `token` already released. `token` should be the address of an IERC20 * contract. */ function totalReleased(IERC20 token) public view returns (uint256) { return _erc20TotalReleased[token]; } /** * @dev Getter for the amount of shares held by an account. */ function shares(address account) public view returns (uint256) { return _shares[account]; } /** * @dev Getter for the amount of Ether already released to a payee. */ function released(address account) public view returns (uint256) { return _released[account]; } /** * @dev Getter for the amount of `token` tokens already released to a payee. `token` should be the address of an * IERC20 contract. */ function released(IERC20 token, address account) public view returns (uint256) { return _erc20Released[token][account]; } /** * @dev Getter for the address of the payee number `index`. */ function payee(uint256 index) public view returns (address) { return _payees[index]; } /** * @dev Triggers a transfer to `account` of the amount of Ether they are owed, according to their percentage of the * total shares and their previous withdrawals. */ function release(address payable account) public virtual { require(_shares[account] > 0, "PaymentSplitter: account has no shares"); uint256 totalReceived = address(this).balance + totalReleased(); uint256 payment = _pendingPayment(account, totalReceived, released(account)); if (payment != 0) { _released[account] += payment; _totalReleased += payment; Address.sendValue(account, payment); emit PaymentReleased(account, payment); } else { emit Warning("PaymentSplitter: account is not due payment"); } } /** * @dev Triggers a transfer to `account` of the amount of `token` tokens they are owed, according to their * percentage of the total shares and their previous withdrawals. `token` must be the address of an IERC20 * contract. */ function release(IERC20 token, address account) public virtual { require(_shares[account] > 0, "PaymentSplitter: account has no shares"); uint256 totalReceived = token.balanceOf(address(this)) + totalReleased(token); uint256 payment = _pendingPayment(account, totalReceived, released(token, account)); if (payment != 0) { _erc20Released[token][account] += payment; _erc20TotalReleased[token] += payment; SafeERC20.safeTransfer(token, account, payment); emit ERC20PaymentReleased(token, account, payment); } else { emit Warning("PaymentSplitter: account is not due payment"); } } /** * @dev internal logic for computing the pending payment of an `account` given the token historical balances and * already released amounts. */ function _pendingPayment( address account, uint256 totalReceived, uint256 alreadyReleased ) private view returns (uint256) { return (totalReceived * _shares[account]) / _totalShares - alreadyReleased; } /** * @dev Add a new payee to the contract. * @param account The address of the payee to add. * @param shares_ The number of shares owned by the payee. */ function _addPayee(address account, uint256 shares_) private { require(account != address(0), "PaymentSplitter: account is the zero address"); require(shares_ > 0, "PaymentSplitter: shares are 0"); require(_shares[account] == 0, "PaymentSplitter: account already has shares"); _payees.push(account); _shares[account] = shares_; _totalShares = _totalShares + shares_; emit PayeeAdded(account, shares_); } }
/** * @title PaymentSplitter * @dev This contract allows to split Ether payments among a group of accounts. The sender does not need to be aware * that the Ether will be split in this way, since it is handled transparently by the contract. * * The split can be in equal parts or in any other arbitrary proportion. The way this is specified is by assigning each * account to a number of shares. Of all the Ether that this contract receives, each account will then be able to claim * an amount proportional to the percentage of total shares they were assigned. * * `PaymentSplitter` follows a _pull payment_ model. This means that payments are not automatically forwarded to the * accounts but kept in this contract, and the actual transfer is triggered as a separate step by calling the {release} * function. * * NOTE: This contract assumes that ERC20 tokens will behave similarly to native tokens (Ether). Rebasing tokens, and * tokens that apply fees during transfers, are likely to not be supported as expected. If in doubt, we encourage you * to run tests before sending real value to this contract. */
NatSpecMultiLine
_pendingPayment
function _pendingPayment( address account, uint256 totalReceived, uint256 alreadyReleased ) private view returns (uint256) { return (totalReceived * _shares[account]) / _totalShares - alreadyReleased; }
/** * @dev internal logic for computing the pending payment of an `account` given the token historical balances and * already released amounts. */
NatSpecMultiLine
v0.8.7+commit.e28d00a7
MIT
ipfs://414d9951eb094e9f3eecc45ff7dcf1c7de317858d1ad8616b1355e70b4b69e2c
{ "func_code_index": [ 5656, 5909 ] }
58,680
MegaMilionsGangstarApes
MegaMilionsGangstarApes.sol
0x3af32fd45224c502469af10e8fff285c18a978bc
Solidity
PaymentSplitter
contract PaymentSplitter is Context { event PayeeAdded(address account, uint256 shares); event PaymentReleased(address to, uint256 amount); event ERC20PaymentReleased(IERC20 indexed token, address to, uint256 amount); event PaymentReceived(address from, uint256 amount); event Warning(string message); uint256 private _totalShares = 50000; uint256 private _totalReleased; mapping(address => uint256) private _shares; mapping(address => uint256) private _released; address[] private _payees; mapping(IERC20 => uint256) private _erc20TotalReleased; mapping(IERC20 => mapping(address => uint256)) private _erc20Released; /** * @dev Creates an instance of `PaymentSplitter` where each account in `payees` is assigned the number of shares at * the matching position in the `shares` array. * * All addresses in `payees` must be non-zero. Both arrays must have the same non-zero length, and there must be no * duplicates in `payees`. */ constructor(address[] memory payees, uint256[] memory shares_) payable { require(payees.length == shares_.length, "PaymentSplitter: payees and shares length mismatch"); require(payees.length > 0, "PaymentSplitter: no payees"); for (uint256 i = 0; i < payees.length; i++) { _addPayee(payees[i], shares_[i]); } } /** * @dev The Ether received will be logged with {PaymentReceived} events. Note that these events are not fully * reliable: it's possible for a contract to receive Ether without triggering this function. This only affects the * reliability of the events, and not the actual splitting of Ether. * * To learn more about this see the Solidity documentation for * https://solidity.readthedocs.io/en/latest/contracts.html#fallback-function[fallback * functions]. */ receive() external payable virtual { emit PaymentReceived(_msgSender(), msg.value); } function addToReleased(uint256 amount) internal { _totalReleased += amount; } /** * @dev Getter for the total shares held by payees. */ function totalShares() public view returns (uint256) { return _totalShares; } /** * @dev Getter for the total amount of Ether already released. */ function totalReleased() public view returns (uint256) { return _totalReleased; } /** * @dev Getter for the total amount of `token` already released. `token` should be the address of an IERC20 * contract. */ function totalReleased(IERC20 token) public view returns (uint256) { return _erc20TotalReleased[token]; } /** * @dev Getter for the amount of shares held by an account. */ function shares(address account) public view returns (uint256) { return _shares[account]; } /** * @dev Getter for the amount of Ether already released to a payee. */ function released(address account) public view returns (uint256) { return _released[account]; } /** * @dev Getter for the amount of `token` tokens already released to a payee. `token` should be the address of an * IERC20 contract. */ function released(IERC20 token, address account) public view returns (uint256) { return _erc20Released[token][account]; } /** * @dev Getter for the address of the payee number `index`. */ function payee(uint256 index) public view returns (address) { return _payees[index]; } /** * @dev Triggers a transfer to `account` of the amount of Ether they are owed, according to their percentage of the * total shares and their previous withdrawals. */ function release(address payable account) public virtual { require(_shares[account] > 0, "PaymentSplitter: account has no shares"); uint256 totalReceived = address(this).balance + totalReleased(); uint256 payment = _pendingPayment(account, totalReceived, released(account)); if (payment != 0) { _released[account] += payment; _totalReleased += payment; Address.sendValue(account, payment); emit PaymentReleased(account, payment); } else { emit Warning("PaymentSplitter: account is not due payment"); } } /** * @dev Triggers a transfer to `account` of the amount of `token` tokens they are owed, according to their * percentage of the total shares and their previous withdrawals. `token` must be the address of an IERC20 * contract. */ function release(IERC20 token, address account) public virtual { require(_shares[account] > 0, "PaymentSplitter: account has no shares"); uint256 totalReceived = token.balanceOf(address(this)) + totalReleased(token); uint256 payment = _pendingPayment(account, totalReceived, released(token, account)); if (payment != 0) { _erc20Released[token][account] += payment; _erc20TotalReleased[token] += payment; SafeERC20.safeTransfer(token, account, payment); emit ERC20PaymentReleased(token, account, payment); } else { emit Warning("PaymentSplitter: account is not due payment"); } } /** * @dev internal logic for computing the pending payment of an `account` given the token historical balances and * already released amounts. */ function _pendingPayment( address account, uint256 totalReceived, uint256 alreadyReleased ) private view returns (uint256) { return (totalReceived * _shares[account]) / _totalShares - alreadyReleased; } /** * @dev Add a new payee to the contract. * @param account The address of the payee to add. * @param shares_ The number of shares owned by the payee. */ function _addPayee(address account, uint256 shares_) private { require(account != address(0), "PaymentSplitter: account is the zero address"); require(shares_ > 0, "PaymentSplitter: shares are 0"); require(_shares[account] == 0, "PaymentSplitter: account already has shares"); _payees.push(account); _shares[account] = shares_; _totalShares = _totalShares + shares_; emit PayeeAdded(account, shares_); } }
/** * @title PaymentSplitter * @dev This contract allows to split Ether payments among a group of accounts. The sender does not need to be aware * that the Ether will be split in this way, since it is handled transparently by the contract. * * The split can be in equal parts or in any other arbitrary proportion. The way this is specified is by assigning each * account to a number of shares. Of all the Ether that this contract receives, each account will then be able to claim * an amount proportional to the percentage of total shares they were assigned. * * `PaymentSplitter` follows a _pull payment_ model. This means that payments are not automatically forwarded to the * accounts but kept in this contract, and the actual transfer is triggered as a separate step by calling the {release} * function. * * NOTE: This contract assumes that ERC20 tokens will behave similarly to native tokens (Ether). Rebasing tokens, and * tokens that apply fees during transfers, are likely to not be supported as expected. If in doubt, we encourage you * to run tests before sending real value to this contract. */
NatSpecMultiLine
_addPayee
function _addPayee(address account, uint256 shares_) private { require(account != address(0), "PaymentSplitter: account is the zero address"); require(shares_ > 0, "PaymentSplitter: shares are 0"); require(_shares[account] == 0, "PaymentSplitter: account already has shares"); _payees.push(account); _shares[account] = shares_; _totalShares = _totalShares + shares_; emit PayeeAdded(account, shares_); }
/** * @dev Add a new payee to the contract. * @param account The address of the payee to add. * @param shares_ The number of shares owned by the payee. */
NatSpecMultiLine
v0.8.7+commit.e28d00a7
MIT
ipfs://414d9951eb094e9f3eecc45ff7dcf1c7de317858d1ad8616b1355e70b4b69e2c
{ "func_code_index": [ 6096, 6574 ] }
58,681
MegaMilionsGangstarApes
MegaMilionsGangstarApes.sol
0x3af32fd45224c502469af10e8fff285c18a978bc
Solidity
MegaMilionsGangstarApes
contract MegaMilionsGangstarApes is ERC721, ERC721Enumerable, ERC721URIStorage, ERC2981ContractWideRoyalties, Ownable, PaymentSplitter { using Counters for Counters.Counter; using Strings for uint; using Math for uint; using SafeMath for uint; enum PriceType{ PROMO, FULL } //{ 0, 1 } struct Promo { uint startTime; uint duration; } // Mappings mapping(address => bool) public whitelisted; mapping(address => uint) public promos; mapping(address => bool) public admins; // Default values uint internal constant MILLIETHER = 1e15; //0.001 ETHER = 1,000,000,000,000,000 WEI uint internal promoPrice = 0.1 ether; uint internal fullPrice = 0.3 ether; uint internal maxSupply = 10000; uint internal maxMint = 10; uint internal maxDiscountedMintPerUser = 2; // Vars string private baseURI; bool private paused = false; Promo private promo; // Wallet shares - 50% of revenues shared to team address private DP = 0xcd70Dc892F240D50b7D46CE120dc75c3243E72ab; address private RG = 0x39c34674EEC3AE5F1E9a6Ee899CB85f11a55D990; address private JH = 0xD484E2745d27FA62E6ab0396fd46e0A3E3A00eFc; address private LH = 0xB2CEe0977Bbb0446B358E0Cb3de69e10EdC5eDA3; address private EA = 0x3a4FF805cD9C063f06a0263EEa99F531FAa13B91; address private AG = 0x79f6E63B4D593F3794019A4FEFB52196C602E037; address private JP = 0xd7EE8aF7a902bb208878E50863220e2872b73992; address private MR = 0xaFBC38a36Cb173d75735f3f781e9133939e99888; address private AF = 0x7a2DD031a02Fd595C7BCb0A278A4518daB31AF8d; address private MA = 0xEe3642cb451F6f4ec5C6dd6699fFE69F2D07921E; uint[] private _shares = [ 675, 675, 11250, 6750, 9865, 6750, 7865, 270, 675, 5225 ]; address[] private _team = [ DP, RG, JH, LH, EA, AG, JP, MR, AF, MA ]; // Game struct RoadmapStep { uint64 supply; uint64 winnersCount; uint64 prizeValue; uint64 winnersToDraw; } uint private drawIndex = 0; RoadmapStep[9] private roadmap; mapping(uint => bool) internal isPrizeGiven; // Modifiers modifier onlyAdmin() { require(address(this) == _msgSender() || owner() == _msgSender() || admins[msg.sender], "Not admin"); _; } // Emitters event BaseURIChanged(string tokenBaseURI); event TicketPriceChanged(PriceType priceType, uint price); event MaxMintAmountChanged(uint amount); event MaxDiscountedMintPerUser(uint mintPerUser); event Paused(bool paused); event PromoChanged(uint startTime, uint duration); event Airdropped(address to, uint tokenId); event Winner(uint token, address winner, uint value); event Log(string error); constructor() ERC721("Mega Millions Gangstar Apes", "MMGA") PaymentSplitter(_team, _shares) { //set default admins admins[DP] = true; admins[RG] = true; initRoadmap(); //if ERC2981 supported _setRoyalties(address(this), 1000); //10% } // *************************** // Overrides // *************************** function _beforeTokenTransfer(address from, address to, uint tokenId) internal override(ERC721, ERC721Enumerable) { super._beforeTokenTransfer(from, to, tokenId); } function supportsInterface(bytes4 interfaceId) public view override(ERC721, ERC721Enumerable, ERC2981Base) returns (bool) { return super.supportsInterface(interfaceId); } function _burn(uint _tokenId) internal override(ERC721, ERC721URIStorage) { super._burn(_tokenId); } function burn(uint _tokenId) external onlyAdmin { _burn(_tokenId); maxSupply = maxSupply - 1; } // *************************** // Admins management by owner // *************************** function enableAdmin(address addr) external onlyOwner { admins[addr] = true; } function disableAdmin(address addr) external onlyOwner { require(addr != owner(), "Can't disable owner"); admins[addr] = false; } // *************************** // Release & withdraw // *************************** function releaseAll() public onlyAdmin { for (uint i = 0; i < _team.length; i++) { address member = _team[i]; try this.release(payable(member)) {} catch Error(string memory revertReason) { emit Log(revertReason); } catch (bytes memory returnData) { emit Log(string(returnData)); } } } function withdraw() external onlyAdmin { releaseAll(); pay(payable(owner()), address(this).balance); } // *************************** // Contract management // *************************** function pause(bool newState) external onlyAdmin { paused = newState; emit Paused(newState); } function addWhitelistedUsers(address[] calldata users) external onlyAdmin { for (uint i = 0; i < users.length; i++) { require(users[i] != address(0), "Can't add a zero address"); if (whitelisted[users[i]] == false) { whitelisted[users[i]] = true; } } } function removeWhitelistedUsers(address[] calldata users) external onlyAdmin { for (uint i = 0; i < users.length; i++) { require(users[i] != address(0), "Can't remove a zero address"); if (whitelisted[users[i]] == true) { whitelisted[users[i]] = false; } } } // Duration in seconds function startPromo(uint duration) external onlyAdmin { uint startTime = block.timestamp; promo = Promo(startTime, duration); emit PromoChanged(startTime, duration); } // *************************** // URI management (Reveal) // *************************** function _baseURI() internal view virtual override returns (string memory) { return baseURI; } function setBaseURI(string memory newBaseURI) external onlyAdmin { baseURI = newBaseURI; emit BaseURIChanged(newBaseURI); } function setTokenURI(uint _tokenId, string memory _tokenURI) external onlyAdmin { require(_exists(_tokenId), "URI set of nonexistent token"); _setTokenURI(_tokenId, _tokenURI); } function tokenURI(uint _tokenId) public view override(ERC721, ERC721URIStorage) returns (string memory) { return super.tokenURI(_tokenId); } // *************************** // Promo & price management // *************************** function setPrice(PriceType priceType, uint price) external onlyAdmin { require(price > 0, "Zero price"); if (priceType == PriceType.PROMO) { promoPrice = price; } else if (priceType == PriceType.FULL) { fullPrice = price; } emit TicketPriceChanged(priceType, price); } function setMaxMintAmount(uint amount) external onlyAdmin { maxMint = amount; emit MaxMintAmountChanged(amount); } function setMaxDiscountedMintPerUser(uint mintPerUser) external onlyAdmin { maxDiscountedMintPerUser = mintPerUser; emit MaxDiscountedMintPerUser(mintPerUser); } function isPromo() public view returns (bool) { return (promo.startTime > 0 && block.timestamp >= promo.startTime && block.timestamp <= (promo.startTime + promo.duration)); } // Dynamically gets the token price according to promo, whitelist and msg.sender function getPrice() public view returns (uint) { uint price = fullPrice; if (admins[msg.sender] == true) { price = 0; } else if ((isPromo() || whitelisted[msg.sender] == true) && promos[msg.sender] < maxDiscountedMintPerUser) { price = promoPrice; } return price; } // *************************** // Mint, Gift & Airdrop // *************************** function mint(address to, uint amount) external payable { uint supply = totalSupply(); bool discounted = (getPrice() == promoPrice); require(!paused, "Contract is paused"); require(amount > 0, "Amount is zero"); require(amount <= maxMint, "Amount exceeds max mint"); require(supply + amount <= maxSupply, "Max supply reached"); if (admins[msg.sender] != true) { if (discounted) { require(promos[to] + amount <= maxDiscountedMintPerUser, "Max discounted NFT exceeded for this user"); } require(getPrice().mul(amount) == msg.value, "Ether value sent is not correct"); } for (uint i = 1; i <= amount; i++) { _safeMint(to, supply + i); if(discounted) { promos[to] = promos[to] + 1; } } } function gift(address to, uint amount) external onlyAdmin { uint supply = totalSupply(); require(!paused, "Contract is paused"); require(amount > 0, "Amount is zero"); require(amount <= maxMint, "Amount exceeds max mint"); require(supply + amount <= maxSupply, "Max supply reached"); for (uint i = 1; i <= amount; i++) { _safeMint(to, supply + i); } } function airdrop(address to, uint tokenId) external onlyAdmin { require(!paused, "Contract is paused"); require(to != address(0), "Can't airdrop to a zero address"); safeTransferFrom(msg.sender, to, tokenId); emit Airdropped(to, tokenId); } // *************************** // Game management // *************************** // Main function to draw the roadmap prizes and pay the winners function draw() external payable onlyAdmin { require(!paused, "Contract is paused"); releaseAll(); uint[] memory prizes = consumeRoadmapPrizes(totalSupply()); uint nonce = block.difficulty; for (uint i = 0; i < prizes.length; i++) { uint tokenId = randToken(i, nonce); require(tokenId != 0, "Incorrect tokenId"); address winner = ownerOf(tokenId); require(winner != address(0), "Can't pay a zero address"); pay(payable(winner), (prizes[i] * MILLIETHER)); nonce=nonce^uint(keccak256(abi.encodePacked(winner))); emit Winner(tokenId, winner, prizes[i]); } } // Alternative draw method to choose one random winner with a given prize function drawOne(uint milliEther) external payable onlyAdmin { require(!paused, "Contract is paused"); releaseAll(); uint seed = uint(keccak256(abi.encodePacked(block.coinbase))); uint nonce = uint(keccak256(abi.encodePacked(msg.sender))); uint tokenId = randToken(seed, nonce); require(tokenId != 0, "Incorrect tokenId"); address winner = ownerOf(tokenId); require(winner != address(0), "Can't pay a zero address"); pay(payable(winner), (milliEther * MILLIETHER)); emit Winner(tokenId, winner, milliEther); } // *************************** // Internals // *************************** // Initialize the roadmap function initRoadmap() internal onlyAdmin { roadmap[0] = RoadmapStep(1000,2,22000,1); roadmap[1] = RoadmapStep(2000,3,22000,1); roadmap[2] = RoadmapStep(3000,1,44000,1); roadmap[3] = RoadmapStep(4000,1,44000,1); roadmap[4] = RoadmapStep(5000,50,1100,2); roadmap[5] = RoadmapStep(7000,50,1100,2); roadmap[6] = RoadmapStep(7000,10,11000,1); roadmap[7] = RoadmapStep(10000,1,220000,1); roadmap[8] = RoadmapStep(10000,50,2200,1); } // Consume some prizes according to the roadmap // Rule : winnersCount per week and only one prizeValue same amount at a time. function consumeRoadmapPrizes(uint supply) internal onlyAdmin returns (uint[] memory) { uint index = 0; uint[] memory temp = new uint[](16); for (uint i = 0; i < 9; i++) { isPrizeGiven[roadmap[i].prizeValue] = false; } for (uint i = 0; i < roadmap.length; i++) { if (roadmap[i].supply > supply) { break; } if ((roadmap[i].supply <= supply) && (roadmap[i].winnersCount > 0) && !isPrizeGiven[roadmap[i].prizeValue]) { for (uint j = 0; j < Math.min(roadmap[i].winnersToDraw, roadmap[i].winnersCount); j++) { roadmap[i].winnersCount--; temp[index] = roadmap[i].prizeValue; index++; } isPrizeGiven[roadmap[i].prizeValue] = true; } } uint[] memory prizes = new uint[](index); for (uint i = 0; i < index; i++) { prizes[i] = temp[i]; } return prizes; } // Randomly picks a tokenId function randToken(uint seed, uint nonce) internal view onlyAdmin returns(uint) { uint supply = totalSupply(); if (supply > 0) { uint tokenId = randModulus(supply, seed, nonce); if (tokenId > 0) { return tokenId; } } return 0; } // Pays eth amount to an address function pay(address payable to, uint amount) internal onlyAdmin { require(to != address(0), "Can't pay a zero address"); require(address(this).balance >= amount, "No sufficient fund in contract to pay the address"); (bool sent, bytes memory data) = to.call{value: amount}(""); if (sent) { addToReleased(amount); } require(sent, string(abi.encodePacked("Failed to send Ether:", data))); } // Gets a random number function randModulus(uint max, uint seed, uint nonce) internal view returns(uint) { uint blockNumber = block.number-1; if (block.number>(seed % 256)) { blockNumber=block.number-(seed % 256); } uint rand = uint(keccak256(abi.encodePacked( seed^block.timestamp, block.timestamp, msg.data, nonce, msg.sender, blockhash(blockNumber) ) )) % max; return rand+1; } }
_beforeTokenTransfer
function _beforeTokenTransfer(address from, address to, uint tokenId) internal override(ERC721, ERC721Enumerable) { super._beforeTokenTransfer(from, to, tokenId); }
// *************************** // Overrides // ***************************
LineComment
v0.8.7+commit.e28d00a7
MIT
ipfs://414d9951eb094e9f3eecc45ff7dcf1c7de317858d1ad8616b1355e70b4b69e2c
{ "func_code_index": [ 3445, 3646 ] }
58,682
MegaMilionsGangstarApes
MegaMilionsGangstarApes.sol
0x3af32fd45224c502469af10e8fff285c18a978bc
Solidity
MegaMilionsGangstarApes
contract MegaMilionsGangstarApes is ERC721, ERC721Enumerable, ERC721URIStorage, ERC2981ContractWideRoyalties, Ownable, PaymentSplitter { using Counters for Counters.Counter; using Strings for uint; using Math for uint; using SafeMath for uint; enum PriceType{ PROMO, FULL } //{ 0, 1 } struct Promo { uint startTime; uint duration; } // Mappings mapping(address => bool) public whitelisted; mapping(address => uint) public promos; mapping(address => bool) public admins; // Default values uint internal constant MILLIETHER = 1e15; //0.001 ETHER = 1,000,000,000,000,000 WEI uint internal promoPrice = 0.1 ether; uint internal fullPrice = 0.3 ether; uint internal maxSupply = 10000; uint internal maxMint = 10; uint internal maxDiscountedMintPerUser = 2; // Vars string private baseURI; bool private paused = false; Promo private promo; // Wallet shares - 50% of revenues shared to team address private DP = 0xcd70Dc892F240D50b7D46CE120dc75c3243E72ab; address private RG = 0x39c34674EEC3AE5F1E9a6Ee899CB85f11a55D990; address private JH = 0xD484E2745d27FA62E6ab0396fd46e0A3E3A00eFc; address private LH = 0xB2CEe0977Bbb0446B358E0Cb3de69e10EdC5eDA3; address private EA = 0x3a4FF805cD9C063f06a0263EEa99F531FAa13B91; address private AG = 0x79f6E63B4D593F3794019A4FEFB52196C602E037; address private JP = 0xd7EE8aF7a902bb208878E50863220e2872b73992; address private MR = 0xaFBC38a36Cb173d75735f3f781e9133939e99888; address private AF = 0x7a2DD031a02Fd595C7BCb0A278A4518daB31AF8d; address private MA = 0xEe3642cb451F6f4ec5C6dd6699fFE69F2D07921E; uint[] private _shares = [ 675, 675, 11250, 6750, 9865, 6750, 7865, 270, 675, 5225 ]; address[] private _team = [ DP, RG, JH, LH, EA, AG, JP, MR, AF, MA ]; // Game struct RoadmapStep { uint64 supply; uint64 winnersCount; uint64 prizeValue; uint64 winnersToDraw; } uint private drawIndex = 0; RoadmapStep[9] private roadmap; mapping(uint => bool) internal isPrizeGiven; // Modifiers modifier onlyAdmin() { require(address(this) == _msgSender() || owner() == _msgSender() || admins[msg.sender], "Not admin"); _; } // Emitters event BaseURIChanged(string tokenBaseURI); event TicketPriceChanged(PriceType priceType, uint price); event MaxMintAmountChanged(uint amount); event MaxDiscountedMintPerUser(uint mintPerUser); event Paused(bool paused); event PromoChanged(uint startTime, uint duration); event Airdropped(address to, uint tokenId); event Winner(uint token, address winner, uint value); event Log(string error); constructor() ERC721("Mega Millions Gangstar Apes", "MMGA") PaymentSplitter(_team, _shares) { //set default admins admins[DP] = true; admins[RG] = true; initRoadmap(); //if ERC2981 supported _setRoyalties(address(this), 1000); //10% } // *************************** // Overrides // *************************** function _beforeTokenTransfer(address from, address to, uint tokenId) internal override(ERC721, ERC721Enumerable) { super._beforeTokenTransfer(from, to, tokenId); } function supportsInterface(bytes4 interfaceId) public view override(ERC721, ERC721Enumerable, ERC2981Base) returns (bool) { return super.supportsInterface(interfaceId); } function _burn(uint _tokenId) internal override(ERC721, ERC721URIStorage) { super._burn(_tokenId); } function burn(uint _tokenId) external onlyAdmin { _burn(_tokenId); maxSupply = maxSupply - 1; } // *************************** // Admins management by owner // *************************** function enableAdmin(address addr) external onlyOwner { admins[addr] = true; } function disableAdmin(address addr) external onlyOwner { require(addr != owner(), "Can't disable owner"); admins[addr] = false; } // *************************** // Release & withdraw // *************************** function releaseAll() public onlyAdmin { for (uint i = 0; i < _team.length; i++) { address member = _team[i]; try this.release(payable(member)) {} catch Error(string memory revertReason) { emit Log(revertReason); } catch (bytes memory returnData) { emit Log(string(returnData)); } } } function withdraw() external onlyAdmin { releaseAll(); pay(payable(owner()), address(this).balance); } // *************************** // Contract management // *************************** function pause(bool newState) external onlyAdmin { paused = newState; emit Paused(newState); } function addWhitelistedUsers(address[] calldata users) external onlyAdmin { for (uint i = 0; i < users.length; i++) { require(users[i] != address(0), "Can't add a zero address"); if (whitelisted[users[i]] == false) { whitelisted[users[i]] = true; } } } function removeWhitelistedUsers(address[] calldata users) external onlyAdmin { for (uint i = 0; i < users.length; i++) { require(users[i] != address(0), "Can't remove a zero address"); if (whitelisted[users[i]] == true) { whitelisted[users[i]] = false; } } } // Duration in seconds function startPromo(uint duration) external onlyAdmin { uint startTime = block.timestamp; promo = Promo(startTime, duration); emit PromoChanged(startTime, duration); } // *************************** // URI management (Reveal) // *************************** function _baseURI() internal view virtual override returns (string memory) { return baseURI; } function setBaseURI(string memory newBaseURI) external onlyAdmin { baseURI = newBaseURI; emit BaseURIChanged(newBaseURI); } function setTokenURI(uint _tokenId, string memory _tokenURI) external onlyAdmin { require(_exists(_tokenId), "URI set of nonexistent token"); _setTokenURI(_tokenId, _tokenURI); } function tokenURI(uint _tokenId) public view override(ERC721, ERC721URIStorage) returns (string memory) { return super.tokenURI(_tokenId); } // *************************** // Promo & price management // *************************** function setPrice(PriceType priceType, uint price) external onlyAdmin { require(price > 0, "Zero price"); if (priceType == PriceType.PROMO) { promoPrice = price; } else if (priceType == PriceType.FULL) { fullPrice = price; } emit TicketPriceChanged(priceType, price); } function setMaxMintAmount(uint amount) external onlyAdmin { maxMint = amount; emit MaxMintAmountChanged(amount); } function setMaxDiscountedMintPerUser(uint mintPerUser) external onlyAdmin { maxDiscountedMintPerUser = mintPerUser; emit MaxDiscountedMintPerUser(mintPerUser); } function isPromo() public view returns (bool) { return (promo.startTime > 0 && block.timestamp >= promo.startTime && block.timestamp <= (promo.startTime + promo.duration)); } // Dynamically gets the token price according to promo, whitelist and msg.sender function getPrice() public view returns (uint) { uint price = fullPrice; if (admins[msg.sender] == true) { price = 0; } else if ((isPromo() || whitelisted[msg.sender] == true) && promos[msg.sender] < maxDiscountedMintPerUser) { price = promoPrice; } return price; } // *************************** // Mint, Gift & Airdrop // *************************** function mint(address to, uint amount) external payable { uint supply = totalSupply(); bool discounted = (getPrice() == promoPrice); require(!paused, "Contract is paused"); require(amount > 0, "Amount is zero"); require(amount <= maxMint, "Amount exceeds max mint"); require(supply + amount <= maxSupply, "Max supply reached"); if (admins[msg.sender] != true) { if (discounted) { require(promos[to] + amount <= maxDiscountedMintPerUser, "Max discounted NFT exceeded for this user"); } require(getPrice().mul(amount) == msg.value, "Ether value sent is not correct"); } for (uint i = 1; i <= amount; i++) { _safeMint(to, supply + i); if(discounted) { promos[to] = promos[to] + 1; } } } function gift(address to, uint amount) external onlyAdmin { uint supply = totalSupply(); require(!paused, "Contract is paused"); require(amount > 0, "Amount is zero"); require(amount <= maxMint, "Amount exceeds max mint"); require(supply + amount <= maxSupply, "Max supply reached"); for (uint i = 1; i <= amount; i++) { _safeMint(to, supply + i); } } function airdrop(address to, uint tokenId) external onlyAdmin { require(!paused, "Contract is paused"); require(to != address(0), "Can't airdrop to a zero address"); safeTransferFrom(msg.sender, to, tokenId); emit Airdropped(to, tokenId); } // *************************** // Game management // *************************** // Main function to draw the roadmap prizes and pay the winners function draw() external payable onlyAdmin { require(!paused, "Contract is paused"); releaseAll(); uint[] memory prizes = consumeRoadmapPrizes(totalSupply()); uint nonce = block.difficulty; for (uint i = 0; i < prizes.length; i++) { uint tokenId = randToken(i, nonce); require(tokenId != 0, "Incorrect tokenId"); address winner = ownerOf(tokenId); require(winner != address(0), "Can't pay a zero address"); pay(payable(winner), (prizes[i] * MILLIETHER)); nonce=nonce^uint(keccak256(abi.encodePacked(winner))); emit Winner(tokenId, winner, prizes[i]); } } // Alternative draw method to choose one random winner with a given prize function drawOne(uint milliEther) external payable onlyAdmin { require(!paused, "Contract is paused"); releaseAll(); uint seed = uint(keccak256(abi.encodePacked(block.coinbase))); uint nonce = uint(keccak256(abi.encodePacked(msg.sender))); uint tokenId = randToken(seed, nonce); require(tokenId != 0, "Incorrect tokenId"); address winner = ownerOf(tokenId); require(winner != address(0), "Can't pay a zero address"); pay(payable(winner), (milliEther * MILLIETHER)); emit Winner(tokenId, winner, milliEther); } // *************************** // Internals // *************************** // Initialize the roadmap function initRoadmap() internal onlyAdmin { roadmap[0] = RoadmapStep(1000,2,22000,1); roadmap[1] = RoadmapStep(2000,3,22000,1); roadmap[2] = RoadmapStep(3000,1,44000,1); roadmap[3] = RoadmapStep(4000,1,44000,1); roadmap[4] = RoadmapStep(5000,50,1100,2); roadmap[5] = RoadmapStep(7000,50,1100,2); roadmap[6] = RoadmapStep(7000,10,11000,1); roadmap[7] = RoadmapStep(10000,1,220000,1); roadmap[8] = RoadmapStep(10000,50,2200,1); } // Consume some prizes according to the roadmap // Rule : winnersCount per week and only one prizeValue same amount at a time. function consumeRoadmapPrizes(uint supply) internal onlyAdmin returns (uint[] memory) { uint index = 0; uint[] memory temp = new uint[](16); for (uint i = 0; i < 9; i++) { isPrizeGiven[roadmap[i].prizeValue] = false; } for (uint i = 0; i < roadmap.length; i++) { if (roadmap[i].supply > supply) { break; } if ((roadmap[i].supply <= supply) && (roadmap[i].winnersCount > 0) && !isPrizeGiven[roadmap[i].prizeValue]) { for (uint j = 0; j < Math.min(roadmap[i].winnersToDraw, roadmap[i].winnersCount); j++) { roadmap[i].winnersCount--; temp[index] = roadmap[i].prizeValue; index++; } isPrizeGiven[roadmap[i].prizeValue] = true; } } uint[] memory prizes = new uint[](index); for (uint i = 0; i < index; i++) { prizes[i] = temp[i]; } return prizes; } // Randomly picks a tokenId function randToken(uint seed, uint nonce) internal view onlyAdmin returns(uint) { uint supply = totalSupply(); if (supply > 0) { uint tokenId = randModulus(supply, seed, nonce); if (tokenId > 0) { return tokenId; } } return 0; } // Pays eth amount to an address function pay(address payable to, uint amount) internal onlyAdmin { require(to != address(0), "Can't pay a zero address"); require(address(this).balance >= amount, "No sufficient fund in contract to pay the address"); (bool sent, bytes memory data) = to.call{value: amount}(""); if (sent) { addToReleased(amount); } require(sent, string(abi.encodePacked("Failed to send Ether:", data))); } // Gets a random number function randModulus(uint max, uint seed, uint nonce) internal view returns(uint) { uint blockNumber = block.number-1; if (block.number>(seed % 256)) { blockNumber=block.number-(seed % 256); } uint rand = uint(keccak256(abi.encodePacked( seed^block.timestamp, block.timestamp, msg.data, nonce, msg.sender, blockhash(blockNumber) ) )) % max; return rand+1; } }
enableAdmin
function enableAdmin(address addr) external onlyOwner { admins[addr] = true; }
// *************************** // Admins management by owner // ***************************
LineComment
v0.8.7+commit.e28d00a7
MIT
ipfs://414d9951eb094e9f3eecc45ff7dcf1c7de317858d1ad8616b1355e70b4b69e2c
{ "func_code_index": [ 4260, 4357 ] }
58,683
MegaMilionsGangstarApes
MegaMilionsGangstarApes.sol
0x3af32fd45224c502469af10e8fff285c18a978bc
Solidity
MegaMilionsGangstarApes
contract MegaMilionsGangstarApes is ERC721, ERC721Enumerable, ERC721URIStorage, ERC2981ContractWideRoyalties, Ownable, PaymentSplitter { using Counters for Counters.Counter; using Strings for uint; using Math for uint; using SafeMath for uint; enum PriceType{ PROMO, FULL } //{ 0, 1 } struct Promo { uint startTime; uint duration; } // Mappings mapping(address => bool) public whitelisted; mapping(address => uint) public promos; mapping(address => bool) public admins; // Default values uint internal constant MILLIETHER = 1e15; //0.001 ETHER = 1,000,000,000,000,000 WEI uint internal promoPrice = 0.1 ether; uint internal fullPrice = 0.3 ether; uint internal maxSupply = 10000; uint internal maxMint = 10; uint internal maxDiscountedMintPerUser = 2; // Vars string private baseURI; bool private paused = false; Promo private promo; // Wallet shares - 50% of revenues shared to team address private DP = 0xcd70Dc892F240D50b7D46CE120dc75c3243E72ab; address private RG = 0x39c34674EEC3AE5F1E9a6Ee899CB85f11a55D990; address private JH = 0xD484E2745d27FA62E6ab0396fd46e0A3E3A00eFc; address private LH = 0xB2CEe0977Bbb0446B358E0Cb3de69e10EdC5eDA3; address private EA = 0x3a4FF805cD9C063f06a0263EEa99F531FAa13B91; address private AG = 0x79f6E63B4D593F3794019A4FEFB52196C602E037; address private JP = 0xd7EE8aF7a902bb208878E50863220e2872b73992; address private MR = 0xaFBC38a36Cb173d75735f3f781e9133939e99888; address private AF = 0x7a2DD031a02Fd595C7BCb0A278A4518daB31AF8d; address private MA = 0xEe3642cb451F6f4ec5C6dd6699fFE69F2D07921E; uint[] private _shares = [ 675, 675, 11250, 6750, 9865, 6750, 7865, 270, 675, 5225 ]; address[] private _team = [ DP, RG, JH, LH, EA, AG, JP, MR, AF, MA ]; // Game struct RoadmapStep { uint64 supply; uint64 winnersCount; uint64 prizeValue; uint64 winnersToDraw; } uint private drawIndex = 0; RoadmapStep[9] private roadmap; mapping(uint => bool) internal isPrizeGiven; // Modifiers modifier onlyAdmin() { require(address(this) == _msgSender() || owner() == _msgSender() || admins[msg.sender], "Not admin"); _; } // Emitters event BaseURIChanged(string tokenBaseURI); event TicketPriceChanged(PriceType priceType, uint price); event MaxMintAmountChanged(uint amount); event MaxDiscountedMintPerUser(uint mintPerUser); event Paused(bool paused); event PromoChanged(uint startTime, uint duration); event Airdropped(address to, uint tokenId); event Winner(uint token, address winner, uint value); event Log(string error); constructor() ERC721("Mega Millions Gangstar Apes", "MMGA") PaymentSplitter(_team, _shares) { //set default admins admins[DP] = true; admins[RG] = true; initRoadmap(); //if ERC2981 supported _setRoyalties(address(this), 1000); //10% } // *************************** // Overrides // *************************** function _beforeTokenTransfer(address from, address to, uint tokenId) internal override(ERC721, ERC721Enumerable) { super._beforeTokenTransfer(from, to, tokenId); } function supportsInterface(bytes4 interfaceId) public view override(ERC721, ERC721Enumerable, ERC2981Base) returns (bool) { return super.supportsInterface(interfaceId); } function _burn(uint _tokenId) internal override(ERC721, ERC721URIStorage) { super._burn(_tokenId); } function burn(uint _tokenId) external onlyAdmin { _burn(_tokenId); maxSupply = maxSupply - 1; } // *************************** // Admins management by owner // *************************** function enableAdmin(address addr) external onlyOwner { admins[addr] = true; } function disableAdmin(address addr) external onlyOwner { require(addr != owner(), "Can't disable owner"); admins[addr] = false; } // *************************** // Release & withdraw // *************************** function releaseAll() public onlyAdmin { for (uint i = 0; i < _team.length; i++) { address member = _team[i]; try this.release(payable(member)) {} catch Error(string memory revertReason) { emit Log(revertReason); } catch (bytes memory returnData) { emit Log(string(returnData)); } } } function withdraw() external onlyAdmin { releaseAll(); pay(payable(owner()), address(this).balance); } // *************************** // Contract management // *************************** function pause(bool newState) external onlyAdmin { paused = newState; emit Paused(newState); } function addWhitelistedUsers(address[] calldata users) external onlyAdmin { for (uint i = 0; i < users.length; i++) { require(users[i] != address(0), "Can't add a zero address"); if (whitelisted[users[i]] == false) { whitelisted[users[i]] = true; } } } function removeWhitelistedUsers(address[] calldata users) external onlyAdmin { for (uint i = 0; i < users.length; i++) { require(users[i] != address(0), "Can't remove a zero address"); if (whitelisted[users[i]] == true) { whitelisted[users[i]] = false; } } } // Duration in seconds function startPromo(uint duration) external onlyAdmin { uint startTime = block.timestamp; promo = Promo(startTime, duration); emit PromoChanged(startTime, duration); } // *************************** // URI management (Reveal) // *************************** function _baseURI() internal view virtual override returns (string memory) { return baseURI; } function setBaseURI(string memory newBaseURI) external onlyAdmin { baseURI = newBaseURI; emit BaseURIChanged(newBaseURI); } function setTokenURI(uint _tokenId, string memory _tokenURI) external onlyAdmin { require(_exists(_tokenId), "URI set of nonexistent token"); _setTokenURI(_tokenId, _tokenURI); } function tokenURI(uint _tokenId) public view override(ERC721, ERC721URIStorage) returns (string memory) { return super.tokenURI(_tokenId); } // *************************** // Promo & price management // *************************** function setPrice(PriceType priceType, uint price) external onlyAdmin { require(price > 0, "Zero price"); if (priceType == PriceType.PROMO) { promoPrice = price; } else if (priceType == PriceType.FULL) { fullPrice = price; } emit TicketPriceChanged(priceType, price); } function setMaxMintAmount(uint amount) external onlyAdmin { maxMint = amount; emit MaxMintAmountChanged(amount); } function setMaxDiscountedMintPerUser(uint mintPerUser) external onlyAdmin { maxDiscountedMintPerUser = mintPerUser; emit MaxDiscountedMintPerUser(mintPerUser); } function isPromo() public view returns (bool) { return (promo.startTime > 0 && block.timestamp >= promo.startTime && block.timestamp <= (promo.startTime + promo.duration)); } // Dynamically gets the token price according to promo, whitelist and msg.sender function getPrice() public view returns (uint) { uint price = fullPrice; if (admins[msg.sender] == true) { price = 0; } else if ((isPromo() || whitelisted[msg.sender] == true) && promos[msg.sender] < maxDiscountedMintPerUser) { price = promoPrice; } return price; } // *************************** // Mint, Gift & Airdrop // *************************** function mint(address to, uint amount) external payable { uint supply = totalSupply(); bool discounted = (getPrice() == promoPrice); require(!paused, "Contract is paused"); require(amount > 0, "Amount is zero"); require(amount <= maxMint, "Amount exceeds max mint"); require(supply + amount <= maxSupply, "Max supply reached"); if (admins[msg.sender] != true) { if (discounted) { require(promos[to] + amount <= maxDiscountedMintPerUser, "Max discounted NFT exceeded for this user"); } require(getPrice().mul(amount) == msg.value, "Ether value sent is not correct"); } for (uint i = 1; i <= amount; i++) { _safeMint(to, supply + i); if(discounted) { promos[to] = promos[to] + 1; } } } function gift(address to, uint amount) external onlyAdmin { uint supply = totalSupply(); require(!paused, "Contract is paused"); require(amount > 0, "Amount is zero"); require(amount <= maxMint, "Amount exceeds max mint"); require(supply + amount <= maxSupply, "Max supply reached"); for (uint i = 1; i <= amount; i++) { _safeMint(to, supply + i); } } function airdrop(address to, uint tokenId) external onlyAdmin { require(!paused, "Contract is paused"); require(to != address(0), "Can't airdrop to a zero address"); safeTransferFrom(msg.sender, to, tokenId); emit Airdropped(to, tokenId); } // *************************** // Game management // *************************** // Main function to draw the roadmap prizes and pay the winners function draw() external payable onlyAdmin { require(!paused, "Contract is paused"); releaseAll(); uint[] memory prizes = consumeRoadmapPrizes(totalSupply()); uint nonce = block.difficulty; for (uint i = 0; i < prizes.length; i++) { uint tokenId = randToken(i, nonce); require(tokenId != 0, "Incorrect tokenId"); address winner = ownerOf(tokenId); require(winner != address(0), "Can't pay a zero address"); pay(payable(winner), (prizes[i] * MILLIETHER)); nonce=nonce^uint(keccak256(abi.encodePacked(winner))); emit Winner(tokenId, winner, prizes[i]); } } // Alternative draw method to choose one random winner with a given prize function drawOne(uint milliEther) external payable onlyAdmin { require(!paused, "Contract is paused"); releaseAll(); uint seed = uint(keccak256(abi.encodePacked(block.coinbase))); uint nonce = uint(keccak256(abi.encodePacked(msg.sender))); uint tokenId = randToken(seed, nonce); require(tokenId != 0, "Incorrect tokenId"); address winner = ownerOf(tokenId); require(winner != address(0), "Can't pay a zero address"); pay(payable(winner), (milliEther * MILLIETHER)); emit Winner(tokenId, winner, milliEther); } // *************************** // Internals // *************************** // Initialize the roadmap function initRoadmap() internal onlyAdmin { roadmap[0] = RoadmapStep(1000,2,22000,1); roadmap[1] = RoadmapStep(2000,3,22000,1); roadmap[2] = RoadmapStep(3000,1,44000,1); roadmap[3] = RoadmapStep(4000,1,44000,1); roadmap[4] = RoadmapStep(5000,50,1100,2); roadmap[5] = RoadmapStep(7000,50,1100,2); roadmap[6] = RoadmapStep(7000,10,11000,1); roadmap[7] = RoadmapStep(10000,1,220000,1); roadmap[8] = RoadmapStep(10000,50,2200,1); } // Consume some prizes according to the roadmap // Rule : winnersCount per week and only one prizeValue same amount at a time. function consumeRoadmapPrizes(uint supply) internal onlyAdmin returns (uint[] memory) { uint index = 0; uint[] memory temp = new uint[](16); for (uint i = 0; i < 9; i++) { isPrizeGiven[roadmap[i].prizeValue] = false; } for (uint i = 0; i < roadmap.length; i++) { if (roadmap[i].supply > supply) { break; } if ((roadmap[i].supply <= supply) && (roadmap[i].winnersCount > 0) && !isPrizeGiven[roadmap[i].prizeValue]) { for (uint j = 0; j < Math.min(roadmap[i].winnersToDraw, roadmap[i].winnersCount); j++) { roadmap[i].winnersCount--; temp[index] = roadmap[i].prizeValue; index++; } isPrizeGiven[roadmap[i].prizeValue] = true; } } uint[] memory prizes = new uint[](index); for (uint i = 0; i < index; i++) { prizes[i] = temp[i]; } return prizes; } // Randomly picks a tokenId function randToken(uint seed, uint nonce) internal view onlyAdmin returns(uint) { uint supply = totalSupply(); if (supply > 0) { uint tokenId = randModulus(supply, seed, nonce); if (tokenId > 0) { return tokenId; } } return 0; } // Pays eth amount to an address function pay(address payable to, uint amount) internal onlyAdmin { require(to != address(0), "Can't pay a zero address"); require(address(this).balance >= amount, "No sufficient fund in contract to pay the address"); (bool sent, bytes memory data) = to.call{value: amount}(""); if (sent) { addToReleased(amount); } require(sent, string(abi.encodePacked("Failed to send Ether:", data))); } // Gets a random number function randModulus(uint max, uint seed, uint nonce) internal view returns(uint) { uint blockNumber = block.number-1; if (block.number>(seed % 256)) { blockNumber=block.number-(seed % 256); } uint rand = uint(keccak256(abi.encodePacked( seed^block.timestamp, block.timestamp, msg.data, nonce, msg.sender, blockhash(blockNumber) ) )) % max; return rand+1; } }
releaseAll
function releaseAll() public onlyAdmin { for (uint i = 0; i < _team.length; i++) { address member = _team[i]; try this.release(payable(member)) {} catch Error(string memory revertReason) { emit Log(revertReason); } catch (bytes memory returnData) { emit Log(string(returnData)); } } }
// *************************** // Release & withdraw // ***************************
LineComment
v0.8.7+commit.e28d00a7
MIT
ipfs://414d9951eb094e9f3eecc45ff7dcf1c7de317858d1ad8616b1355e70b4b69e2c
{ "func_code_index": [ 4624, 5035 ] }
58,684
MegaMilionsGangstarApes
MegaMilionsGangstarApes.sol
0x3af32fd45224c502469af10e8fff285c18a978bc
Solidity
MegaMilionsGangstarApes
contract MegaMilionsGangstarApes is ERC721, ERC721Enumerable, ERC721URIStorage, ERC2981ContractWideRoyalties, Ownable, PaymentSplitter { using Counters for Counters.Counter; using Strings for uint; using Math for uint; using SafeMath for uint; enum PriceType{ PROMO, FULL } //{ 0, 1 } struct Promo { uint startTime; uint duration; } // Mappings mapping(address => bool) public whitelisted; mapping(address => uint) public promos; mapping(address => bool) public admins; // Default values uint internal constant MILLIETHER = 1e15; //0.001 ETHER = 1,000,000,000,000,000 WEI uint internal promoPrice = 0.1 ether; uint internal fullPrice = 0.3 ether; uint internal maxSupply = 10000; uint internal maxMint = 10; uint internal maxDiscountedMintPerUser = 2; // Vars string private baseURI; bool private paused = false; Promo private promo; // Wallet shares - 50% of revenues shared to team address private DP = 0xcd70Dc892F240D50b7D46CE120dc75c3243E72ab; address private RG = 0x39c34674EEC3AE5F1E9a6Ee899CB85f11a55D990; address private JH = 0xD484E2745d27FA62E6ab0396fd46e0A3E3A00eFc; address private LH = 0xB2CEe0977Bbb0446B358E0Cb3de69e10EdC5eDA3; address private EA = 0x3a4FF805cD9C063f06a0263EEa99F531FAa13B91; address private AG = 0x79f6E63B4D593F3794019A4FEFB52196C602E037; address private JP = 0xd7EE8aF7a902bb208878E50863220e2872b73992; address private MR = 0xaFBC38a36Cb173d75735f3f781e9133939e99888; address private AF = 0x7a2DD031a02Fd595C7BCb0A278A4518daB31AF8d; address private MA = 0xEe3642cb451F6f4ec5C6dd6699fFE69F2D07921E; uint[] private _shares = [ 675, 675, 11250, 6750, 9865, 6750, 7865, 270, 675, 5225 ]; address[] private _team = [ DP, RG, JH, LH, EA, AG, JP, MR, AF, MA ]; // Game struct RoadmapStep { uint64 supply; uint64 winnersCount; uint64 prizeValue; uint64 winnersToDraw; } uint private drawIndex = 0; RoadmapStep[9] private roadmap; mapping(uint => bool) internal isPrizeGiven; // Modifiers modifier onlyAdmin() { require(address(this) == _msgSender() || owner() == _msgSender() || admins[msg.sender], "Not admin"); _; } // Emitters event BaseURIChanged(string tokenBaseURI); event TicketPriceChanged(PriceType priceType, uint price); event MaxMintAmountChanged(uint amount); event MaxDiscountedMintPerUser(uint mintPerUser); event Paused(bool paused); event PromoChanged(uint startTime, uint duration); event Airdropped(address to, uint tokenId); event Winner(uint token, address winner, uint value); event Log(string error); constructor() ERC721("Mega Millions Gangstar Apes", "MMGA") PaymentSplitter(_team, _shares) { //set default admins admins[DP] = true; admins[RG] = true; initRoadmap(); //if ERC2981 supported _setRoyalties(address(this), 1000); //10% } // *************************** // Overrides // *************************** function _beforeTokenTransfer(address from, address to, uint tokenId) internal override(ERC721, ERC721Enumerable) { super._beforeTokenTransfer(from, to, tokenId); } function supportsInterface(bytes4 interfaceId) public view override(ERC721, ERC721Enumerable, ERC2981Base) returns (bool) { return super.supportsInterface(interfaceId); } function _burn(uint _tokenId) internal override(ERC721, ERC721URIStorage) { super._burn(_tokenId); } function burn(uint _tokenId) external onlyAdmin { _burn(_tokenId); maxSupply = maxSupply - 1; } // *************************** // Admins management by owner // *************************** function enableAdmin(address addr) external onlyOwner { admins[addr] = true; } function disableAdmin(address addr) external onlyOwner { require(addr != owner(), "Can't disable owner"); admins[addr] = false; } // *************************** // Release & withdraw // *************************** function releaseAll() public onlyAdmin { for (uint i = 0; i < _team.length; i++) { address member = _team[i]; try this.release(payable(member)) {} catch Error(string memory revertReason) { emit Log(revertReason); } catch (bytes memory returnData) { emit Log(string(returnData)); } } } function withdraw() external onlyAdmin { releaseAll(); pay(payable(owner()), address(this).balance); } // *************************** // Contract management // *************************** function pause(bool newState) external onlyAdmin { paused = newState; emit Paused(newState); } function addWhitelistedUsers(address[] calldata users) external onlyAdmin { for (uint i = 0; i < users.length; i++) { require(users[i] != address(0), "Can't add a zero address"); if (whitelisted[users[i]] == false) { whitelisted[users[i]] = true; } } } function removeWhitelistedUsers(address[] calldata users) external onlyAdmin { for (uint i = 0; i < users.length; i++) { require(users[i] != address(0), "Can't remove a zero address"); if (whitelisted[users[i]] == true) { whitelisted[users[i]] = false; } } } // Duration in seconds function startPromo(uint duration) external onlyAdmin { uint startTime = block.timestamp; promo = Promo(startTime, duration); emit PromoChanged(startTime, duration); } // *************************** // URI management (Reveal) // *************************** function _baseURI() internal view virtual override returns (string memory) { return baseURI; } function setBaseURI(string memory newBaseURI) external onlyAdmin { baseURI = newBaseURI; emit BaseURIChanged(newBaseURI); } function setTokenURI(uint _tokenId, string memory _tokenURI) external onlyAdmin { require(_exists(_tokenId), "URI set of nonexistent token"); _setTokenURI(_tokenId, _tokenURI); } function tokenURI(uint _tokenId) public view override(ERC721, ERC721URIStorage) returns (string memory) { return super.tokenURI(_tokenId); } // *************************** // Promo & price management // *************************** function setPrice(PriceType priceType, uint price) external onlyAdmin { require(price > 0, "Zero price"); if (priceType == PriceType.PROMO) { promoPrice = price; } else if (priceType == PriceType.FULL) { fullPrice = price; } emit TicketPriceChanged(priceType, price); } function setMaxMintAmount(uint amount) external onlyAdmin { maxMint = amount; emit MaxMintAmountChanged(amount); } function setMaxDiscountedMintPerUser(uint mintPerUser) external onlyAdmin { maxDiscountedMintPerUser = mintPerUser; emit MaxDiscountedMintPerUser(mintPerUser); } function isPromo() public view returns (bool) { return (promo.startTime > 0 && block.timestamp >= promo.startTime && block.timestamp <= (promo.startTime + promo.duration)); } // Dynamically gets the token price according to promo, whitelist and msg.sender function getPrice() public view returns (uint) { uint price = fullPrice; if (admins[msg.sender] == true) { price = 0; } else if ((isPromo() || whitelisted[msg.sender] == true) && promos[msg.sender] < maxDiscountedMintPerUser) { price = promoPrice; } return price; } // *************************** // Mint, Gift & Airdrop // *************************** function mint(address to, uint amount) external payable { uint supply = totalSupply(); bool discounted = (getPrice() == promoPrice); require(!paused, "Contract is paused"); require(amount > 0, "Amount is zero"); require(amount <= maxMint, "Amount exceeds max mint"); require(supply + amount <= maxSupply, "Max supply reached"); if (admins[msg.sender] != true) { if (discounted) { require(promos[to] + amount <= maxDiscountedMintPerUser, "Max discounted NFT exceeded for this user"); } require(getPrice().mul(amount) == msg.value, "Ether value sent is not correct"); } for (uint i = 1; i <= amount; i++) { _safeMint(to, supply + i); if(discounted) { promos[to] = promos[to] + 1; } } } function gift(address to, uint amount) external onlyAdmin { uint supply = totalSupply(); require(!paused, "Contract is paused"); require(amount > 0, "Amount is zero"); require(amount <= maxMint, "Amount exceeds max mint"); require(supply + amount <= maxSupply, "Max supply reached"); for (uint i = 1; i <= amount; i++) { _safeMint(to, supply + i); } } function airdrop(address to, uint tokenId) external onlyAdmin { require(!paused, "Contract is paused"); require(to != address(0), "Can't airdrop to a zero address"); safeTransferFrom(msg.sender, to, tokenId); emit Airdropped(to, tokenId); } // *************************** // Game management // *************************** // Main function to draw the roadmap prizes and pay the winners function draw() external payable onlyAdmin { require(!paused, "Contract is paused"); releaseAll(); uint[] memory prizes = consumeRoadmapPrizes(totalSupply()); uint nonce = block.difficulty; for (uint i = 0; i < prizes.length; i++) { uint tokenId = randToken(i, nonce); require(tokenId != 0, "Incorrect tokenId"); address winner = ownerOf(tokenId); require(winner != address(0), "Can't pay a zero address"); pay(payable(winner), (prizes[i] * MILLIETHER)); nonce=nonce^uint(keccak256(abi.encodePacked(winner))); emit Winner(tokenId, winner, prizes[i]); } } // Alternative draw method to choose one random winner with a given prize function drawOne(uint milliEther) external payable onlyAdmin { require(!paused, "Contract is paused"); releaseAll(); uint seed = uint(keccak256(abi.encodePacked(block.coinbase))); uint nonce = uint(keccak256(abi.encodePacked(msg.sender))); uint tokenId = randToken(seed, nonce); require(tokenId != 0, "Incorrect tokenId"); address winner = ownerOf(tokenId); require(winner != address(0), "Can't pay a zero address"); pay(payable(winner), (milliEther * MILLIETHER)); emit Winner(tokenId, winner, milliEther); } // *************************** // Internals // *************************** // Initialize the roadmap function initRoadmap() internal onlyAdmin { roadmap[0] = RoadmapStep(1000,2,22000,1); roadmap[1] = RoadmapStep(2000,3,22000,1); roadmap[2] = RoadmapStep(3000,1,44000,1); roadmap[3] = RoadmapStep(4000,1,44000,1); roadmap[4] = RoadmapStep(5000,50,1100,2); roadmap[5] = RoadmapStep(7000,50,1100,2); roadmap[6] = RoadmapStep(7000,10,11000,1); roadmap[7] = RoadmapStep(10000,1,220000,1); roadmap[8] = RoadmapStep(10000,50,2200,1); } // Consume some prizes according to the roadmap // Rule : winnersCount per week and only one prizeValue same amount at a time. function consumeRoadmapPrizes(uint supply) internal onlyAdmin returns (uint[] memory) { uint index = 0; uint[] memory temp = new uint[](16); for (uint i = 0; i < 9; i++) { isPrizeGiven[roadmap[i].prizeValue] = false; } for (uint i = 0; i < roadmap.length; i++) { if (roadmap[i].supply > supply) { break; } if ((roadmap[i].supply <= supply) && (roadmap[i].winnersCount > 0) && !isPrizeGiven[roadmap[i].prizeValue]) { for (uint j = 0; j < Math.min(roadmap[i].winnersToDraw, roadmap[i].winnersCount); j++) { roadmap[i].winnersCount--; temp[index] = roadmap[i].prizeValue; index++; } isPrizeGiven[roadmap[i].prizeValue] = true; } } uint[] memory prizes = new uint[](index); for (uint i = 0; i < index; i++) { prizes[i] = temp[i]; } return prizes; } // Randomly picks a tokenId function randToken(uint seed, uint nonce) internal view onlyAdmin returns(uint) { uint supply = totalSupply(); if (supply > 0) { uint tokenId = randModulus(supply, seed, nonce); if (tokenId > 0) { return tokenId; } } return 0; } // Pays eth amount to an address function pay(address payable to, uint amount) internal onlyAdmin { require(to != address(0), "Can't pay a zero address"); require(address(this).balance >= amount, "No sufficient fund in contract to pay the address"); (bool sent, bytes memory data) = to.call{value: amount}(""); if (sent) { addToReleased(amount); } require(sent, string(abi.encodePacked("Failed to send Ether:", data))); } // Gets a random number function randModulus(uint max, uint seed, uint nonce) internal view returns(uint) { uint blockNumber = block.number-1; if (block.number>(seed % 256)) { blockNumber=block.number-(seed % 256); } uint rand = uint(keccak256(abi.encodePacked( seed^block.timestamp, block.timestamp, msg.data, nonce, msg.sender, blockhash(blockNumber) ) )) % max; return rand+1; } }
pause
function pause(bool newState) external onlyAdmin { paused = newState; emit Paused(newState); }
// *************************** // Contract management // ***************************
LineComment
v0.8.7+commit.e28d00a7
MIT
ipfs://414d9951eb094e9f3eecc45ff7dcf1c7de317858d1ad8616b1355e70b4b69e2c
{ "func_code_index": [ 5280, 5402 ] }
58,685
MegaMilionsGangstarApes
MegaMilionsGangstarApes.sol
0x3af32fd45224c502469af10e8fff285c18a978bc
Solidity
MegaMilionsGangstarApes
contract MegaMilionsGangstarApes is ERC721, ERC721Enumerable, ERC721URIStorage, ERC2981ContractWideRoyalties, Ownable, PaymentSplitter { using Counters for Counters.Counter; using Strings for uint; using Math for uint; using SafeMath for uint; enum PriceType{ PROMO, FULL } //{ 0, 1 } struct Promo { uint startTime; uint duration; } // Mappings mapping(address => bool) public whitelisted; mapping(address => uint) public promos; mapping(address => bool) public admins; // Default values uint internal constant MILLIETHER = 1e15; //0.001 ETHER = 1,000,000,000,000,000 WEI uint internal promoPrice = 0.1 ether; uint internal fullPrice = 0.3 ether; uint internal maxSupply = 10000; uint internal maxMint = 10; uint internal maxDiscountedMintPerUser = 2; // Vars string private baseURI; bool private paused = false; Promo private promo; // Wallet shares - 50% of revenues shared to team address private DP = 0xcd70Dc892F240D50b7D46CE120dc75c3243E72ab; address private RG = 0x39c34674EEC3AE5F1E9a6Ee899CB85f11a55D990; address private JH = 0xD484E2745d27FA62E6ab0396fd46e0A3E3A00eFc; address private LH = 0xB2CEe0977Bbb0446B358E0Cb3de69e10EdC5eDA3; address private EA = 0x3a4FF805cD9C063f06a0263EEa99F531FAa13B91; address private AG = 0x79f6E63B4D593F3794019A4FEFB52196C602E037; address private JP = 0xd7EE8aF7a902bb208878E50863220e2872b73992; address private MR = 0xaFBC38a36Cb173d75735f3f781e9133939e99888; address private AF = 0x7a2DD031a02Fd595C7BCb0A278A4518daB31AF8d; address private MA = 0xEe3642cb451F6f4ec5C6dd6699fFE69F2D07921E; uint[] private _shares = [ 675, 675, 11250, 6750, 9865, 6750, 7865, 270, 675, 5225 ]; address[] private _team = [ DP, RG, JH, LH, EA, AG, JP, MR, AF, MA ]; // Game struct RoadmapStep { uint64 supply; uint64 winnersCount; uint64 prizeValue; uint64 winnersToDraw; } uint private drawIndex = 0; RoadmapStep[9] private roadmap; mapping(uint => bool) internal isPrizeGiven; // Modifiers modifier onlyAdmin() { require(address(this) == _msgSender() || owner() == _msgSender() || admins[msg.sender], "Not admin"); _; } // Emitters event BaseURIChanged(string tokenBaseURI); event TicketPriceChanged(PriceType priceType, uint price); event MaxMintAmountChanged(uint amount); event MaxDiscountedMintPerUser(uint mintPerUser); event Paused(bool paused); event PromoChanged(uint startTime, uint duration); event Airdropped(address to, uint tokenId); event Winner(uint token, address winner, uint value); event Log(string error); constructor() ERC721("Mega Millions Gangstar Apes", "MMGA") PaymentSplitter(_team, _shares) { //set default admins admins[DP] = true; admins[RG] = true; initRoadmap(); //if ERC2981 supported _setRoyalties(address(this), 1000); //10% } // *************************** // Overrides // *************************** function _beforeTokenTransfer(address from, address to, uint tokenId) internal override(ERC721, ERC721Enumerable) { super._beforeTokenTransfer(from, to, tokenId); } function supportsInterface(bytes4 interfaceId) public view override(ERC721, ERC721Enumerable, ERC2981Base) returns (bool) { return super.supportsInterface(interfaceId); } function _burn(uint _tokenId) internal override(ERC721, ERC721URIStorage) { super._burn(_tokenId); } function burn(uint _tokenId) external onlyAdmin { _burn(_tokenId); maxSupply = maxSupply - 1; } // *************************** // Admins management by owner // *************************** function enableAdmin(address addr) external onlyOwner { admins[addr] = true; } function disableAdmin(address addr) external onlyOwner { require(addr != owner(), "Can't disable owner"); admins[addr] = false; } // *************************** // Release & withdraw // *************************** function releaseAll() public onlyAdmin { for (uint i = 0; i < _team.length; i++) { address member = _team[i]; try this.release(payable(member)) {} catch Error(string memory revertReason) { emit Log(revertReason); } catch (bytes memory returnData) { emit Log(string(returnData)); } } } function withdraw() external onlyAdmin { releaseAll(); pay(payable(owner()), address(this).balance); } // *************************** // Contract management // *************************** function pause(bool newState) external onlyAdmin { paused = newState; emit Paused(newState); } function addWhitelistedUsers(address[] calldata users) external onlyAdmin { for (uint i = 0; i < users.length; i++) { require(users[i] != address(0), "Can't add a zero address"); if (whitelisted[users[i]] == false) { whitelisted[users[i]] = true; } } } function removeWhitelistedUsers(address[] calldata users) external onlyAdmin { for (uint i = 0; i < users.length; i++) { require(users[i] != address(0), "Can't remove a zero address"); if (whitelisted[users[i]] == true) { whitelisted[users[i]] = false; } } } // Duration in seconds function startPromo(uint duration) external onlyAdmin { uint startTime = block.timestamp; promo = Promo(startTime, duration); emit PromoChanged(startTime, duration); } // *************************** // URI management (Reveal) // *************************** function _baseURI() internal view virtual override returns (string memory) { return baseURI; } function setBaseURI(string memory newBaseURI) external onlyAdmin { baseURI = newBaseURI; emit BaseURIChanged(newBaseURI); } function setTokenURI(uint _tokenId, string memory _tokenURI) external onlyAdmin { require(_exists(_tokenId), "URI set of nonexistent token"); _setTokenURI(_tokenId, _tokenURI); } function tokenURI(uint _tokenId) public view override(ERC721, ERC721URIStorage) returns (string memory) { return super.tokenURI(_tokenId); } // *************************** // Promo & price management // *************************** function setPrice(PriceType priceType, uint price) external onlyAdmin { require(price > 0, "Zero price"); if (priceType == PriceType.PROMO) { promoPrice = price; } else if (priceType == PriceType.FULL) { fullPrice = price; } emit TicketPriceChanged(priceType, price); } function setMaxMintAmount(uint amount) external onlyAdmin { maxMint = amount; emit MaxMintAmountChanged(amount); } function setMaxDiscountedMintPerUser(uint mintPerUser) external onlyAdmin { maxDiscountedMintPerUser = mintPerUser; emit MaxDiscountedMintPerUser(mintPerUser); } function isPromo() public view returns (bool) { return (promo.startTime > 0 && block.timestamp >= promo.startTime && block.timestamp <= (promo.startTime + promo.duration)); } // Dynamically gets the token price according to promo, whitelist and msg.sender function getPrice() public view returns (uint) { uint price = fullPrice; if (admins[msg.sender] == true) { price = 0; } else if ((isPromo() || whitelisted[msg.sender] == true) && promos[msg.sender] < maxDiscountedMintPerUser) { price = promoPrice; } return price; } // *************************** // Mint, Gift & Airdrop // *************************** function mint(address to, uint amount) external payable { uint supply = totalSupply(); bool discounted = (getPrice() == promoPrice); require(!paused, "Contract is paused"); require(amount > 0, "Amount is zero"); require(amount <= maxMint, "Amount exceeds max mint"); require(supply + amount <= maxSupply, "Max supply reached"); if (admins[msg.sender] != true) { if (discounted) { require(promos[to] + amount <= maxDiscountedMintPerUser, "Max discounted NFT exceeded for this user"); } require(getPrice().mul(amount) == msg.value, "Ether value sent is not correct"); } for (uint i = 1; i <= amount; i++) { _safeMint(to, supply + i); if(discounted) { promos[to] = promos[to] + 1; } } } function gift(address to, uint amount) external onlyAdmin { uint supply = totalSupply(); require(!paused, "Contract is paused"); require(amount > 0, "Amount is zero"); require(amount <= maxMint, "Amount exceeds max mint"); require(supply + amount <= maxSupply, "Max supply reached"); for (uint i = 1; i <= amount; i++) { _safeMint(to, supply + i); } } function airdrop(address to, uint tokenId) external onlyAdmin { require(!paused, "Contract is paused"); require(to != address(0), "Can't airdrop to a zero address"); safeTransferFrom(msg.sender, to, tokenId); emit Airdropped(to, tokenId); } // *************************** // Game management // *************************** // Main function to draw the roadmap prizes and pay the winners function draw() external payable onlyAdmin { require(!paused, "Contract is paused"); releaseAll(); uint[] memory prizes = consumeRoadmapPrizes(totalSupply()); uint nonce = block.difficulty; for (uint i = 0; i < prizes.length; i++) { uint tokenId = randToken(i, nonce); require(tokenId != 0, "Incorrect tokenId"); address winner = ownerOf(tokenId); require(winner != address(0), "Can't pay a zero address"); pay(payable(winner), (prizes[i] * MILLIETHER)); nonce=nonce^uint(keccak256(abi.encodePacked(winner))); emit Winner(tokenId, winner, prizes[i]); } } // Alternative draw method to choose one random winner with a given prize function drawOne(uint milliEther) external payable onlyAdmin { require(!paused, "Contract is paused"); releaseAll(); uint seed = uint(keccak256(abi.encodePacked(block.coinbase))); uint nonce = uint(keccak256(abi.encodePacked(msg.sender))); uint tokenId = randToken(seed, nonce); require(tokenId != 0, "Incorrect tokenId"); address winner = ownerOf(tokenId); require(winner != address(0), "Can't pay a zero address"); pay(payable(winner), (milliEther * MILLIETHER)); emit Winner(tokenId, winner, milliEther); } // *************************** // Internals // *************************** // Initialize the roadmap function initRoadmap() internal onlyAdmin { roadmap[0] = RoadmapStep(1000,2,22000,1); roadmap[1] = RoadmapStep(2000,3,22000,1); roadmap[2] = RoadmapStep(3000,1,44000,1); roadmap[3] = RoadmapStep(4000,1,44000,1); roadmap[4] = RoadmapStep(5000,50,1100,2); roadmap[5] = RoadmapStep(7000,50,1100,2); roadmap[6] = RoadmapStep(7000,10,11000,1); roadmap[7] = RoadmapStep(10000,1,220000,1); roadmap[8] = RoadmapStep(10000,50,2200,1); } // Consume some prizes according to the roadmap // Rule : winnersCount per week and only one prizeValue same amount at a time. function consumeRoadmapPrizes(uint supply) internal onlyAdmin returns (uint[] memory) { uint index = 0; uint[] memory temp = new uint[](16); for (uint i = 0; i < 9; i++) { isPrizeGiven[roadmap[i].prizeValue] = false; } for (uint i = 0; i < roadmap.length; i++) { if (roadmap[i].supply > supply) { break; } if ((roadmap[i].supply <= supply) && (roadmap[i].winnersCount > 0) && !isPrizeGiven[roadmap[i].prizeValue]) { for (uint j = 0; j < Math.min(roadmap[i].winnersToDraw, roadmap[i].winnersCount); j++) { roadmap[i].winnersCount--; temp[index] = roadmap[i].prizeValue; index++; } isPrizeGiven[roadmap[i].prizeValue] = true; } } uint[] memory prizes = new uint[](index); for (uint i = 0; i < index; i++) { prizes[i] = temp[i]; } return prizes; } // Randomly picks a tokenId function randToken(uint seed, uint nonce) internal view onlyAdmin returns(uint) { uint supply = totalSupply(); if (supply > 0) { uint tokenId = randModulus(supply, seed, nonce); if (tokenId > 0) { return tokenId; } } return 0; } // Pays eth amount to an address function pay(address payable to, uint amount) internal onlyAdmin { require(to != address(0), "Can't pay a zero address"); require(address(this).balance >= amount, "No sufficient fund in contract to pay the address"); (bool sent, bytes memory data) = to.call{value: amount}(""); if (sent) { addToReleased(amount); } require(sent, string(abi.encodePacked("Failed to send Ether:", data))); } // Gets a random number function randModulus(uint max, uint seed, uint nonce) internal view returns(uint) { uint blockNumber = block.number-1; if (block.number>(seed % 256)) { blockNumber=block.number-(seed % 256); } uint rand = uint(keccak256(abi.encodePacked( seed^block.timestamp, block.timestamp, msg.data, nonce, msg.sender, blockhash(blockNumber) ) )) % max; return rand+1; } }
startPromo
function startPromo(uint duration) external onlyAdmin { uint startTime = block.timestamp; promo = Promo(startTime, duration); emit PromoChanged(startTime, duration); }
// Duration in seconds
LineComment
v0.8.7+commit.e28d00a7
MIT
ipfs://414d9951eb094e9f3eecc45ff7dcf1c7de317858d1ad8616b1355e70b4b69e2c
{ "func_code_index": [ 6117, 6321 ] }
58,686
MegaMilionsGangstarApes
MegaMilionsGangstarApes.sol
0x3af32fd45224c502469af10e8fff285c18a978bc
Solidity
MegaMilionsGangstarApes
contract MegaMilionsGangstarApes is ERC721, ERC721Enumerable, ERC721URIStorage, ERC2981ContractWideRoyalties, Ownable, PaymentSplitter { using Counters for Counters.Counter; using Strings for uint; using Math for uint; using SafeMath for uint; enum PriceType{ PROMO, FULL } //{ 0, 1 } struct Promo { uint startTime; uint duration; } // Mappings mapping(address => bool) public whitelisted; mapping(address => uint) public promos; mapping(address => bool) public admins; // Default values uint internal constant MILLIETHER = 1e15; //0.001 ETHER = 1,000,000,000,000,000 WEI uint internal promoPrice = 0.1 ether; uint internal fullPrice = 0.3 ether; uint internal maxSupply = 10000; uint internal maxMint = 10; uint internal maxDiscountedMintPerUser = 2; // Vars string private baseURI; bool private paused = false; Promo private promo; // Wallet shares - 50% of revenues shared to team address private DP = 0xcd70Dc892F240D50b7D46CE120dc75c3243E72ab; address private RG = 0x39c34674EEC3AE5F1E9a6Ee899CB85f11a55D990; address private JH = 0xD484E2745d27FA62E6ab0396fd46e0A3E3A00eFc; address private LH = 0xB2CEe0977Bbb0446B358E0Cb3de69e10EdC5eDA3; address private EA = 0x3a4FF805cD9C063f06a0263EEa99F531FAa13B91; address private AG = 0x79f6E63B4D593F3794019A4FEFB52196C602E037; address private JP = 0xd7EE8aF7a902bb208878E50863220e2872b73992; address private MR = 0xaFBC38a36Cb173d75735f3f781e9133939e99888; address private AF = 0x7a2DD031a02Fd595C7BCb0A278A4518daB31AF8d; address private MA = 0xEe3642cb451F6f4ec5C6dd6699fFE69F2D07921E; uint[] private _shares = [ 675, 675, 11250, 6750, 9865, 6750, 7865, 270, 675, 5225 ]; address[] private _team = [ DP, RG, JH, LH, EA, AG, JP, MR, AF, MA ]; // Game struct RoadmapStep { uint64 supply; uint64 winnersCount; uint64 prizeValue; uint64 winnersToDraw; } uint private drawIndex = 0; RoadmapStep[9] private roadmap; mapping(uint => bool) internal isPrizeGiven; // Modifiers modifier onlyAdmin() { require(address(this) == _msgSender() || owner() == _msgSender() || admins[msg.sender], "Not admin"); _; } // Emitters event BaseURIChanged(string tokenBaseURI); event TicketPriceChanged(PriceType priceType, uint price); event MaxMintAmountChanged(uint amount); event MaxDiscountedMintPerUser(uint mintPerUser); event Paused(bool paused); event PromoChanged(uint startTime, uint duration); event Airdropped(address to, uint tokenId); event Winner(uint token, address winner, uint value); event Log(string error); constructor() ERC721("Mega Millions Gangstar Apes", "MMGA") PaymentSplitter(_team, _shares) { //set default admins admins[DP] = true; admins[RG] = true; initRoadmap(); //if ERC2981 supported _setRoyalties(address(this), 1000); //10% } // *************************** // Overrides // *************************** function _beforeTokenTransfer(address from, address to, uint tokenId) internal override(ERC721, ERC721Enumerable) { super._beforeTokenTransfer(from, to, tokenId); } function supportsInterface(bytes4 interfaceId) public view override(ERC721, ERC721Enumerable, ERC2981Base) returns (bool) { return super.supportsInterface(interfaceId); } function _burn(uint _tokenId) internal override(ERC721, ERC721URIStorage) { super._burn(_tokenId); } function burn(uint _tokenId) external onlyAdmin { _burn(_tokenId); maxSupply = maxSupply - 1; } // *************************** // Admins management by owner // *************************** function enableAdmin(address addr) external onlyOwner { admins[addr] = true; } function disableAdmin(address addr) external onlyOwner { require(addr != owner(), "Can't disable owner"); admins[addr] = false; } // *************************** // Release & withdraw // *************************** function releaseAll() public onlyAdmin { for (uint i = 0; i < _team.length; i++) { address member = _team[i]; try this.release(payable(member)) {} catch Error(string memory revertReason) { emit Log(revertReason); } catch (bytes memory returnData) { emit Log(string(returnData)); } } } function withdraw() external onlyAdmin { releaseAll(); pay(payable(owner()), address(this).balance); } // *************************** // Contract management // *************************** function pause(bool newState) external onlyAdmin { paused = newState; emit Paused(newState); } function addWhitelistedUsers(address[] calldata users) external onlyAdmin { for (uint i = 0; i < users.length; i++) { require(users[i] != address(0), "Can't add a zero address"); if (whitelisted[users[i]] == false) { whitelisted[users[i]] = true; } } } function removeWhitelistedUsers(address[] calldata users) external onlyAdmin { for (uint i = 0; i < users.length; i++) { require(users[i] != address(0), "Can't remove a zero address"); if (whitelisted[users[i]] == true) { whitelisted[users[i]] = false; } } } // Duration in seconds function startPromo(uint duration) external onlyAdmin { uint startTime = block.timestamp; promo = Promo(startTime, duration); emit PromoChanged(startTime, duration); } // *************************** // URI management (Reveal) // *************************** function _baseURI() internal view virtual override returns (string memory) { return baseURI; } function setBaseURI(string memory newBaseURI) external onlyAdmin { baseURI = newBaseURI; emit BaseURIChanged(newBaseURI); } function setTokenURI(uint _tokenId, string memory _tokenURI) external onlyAdmin { require(_exists(_tokenId), "URI set of nonexistent token"); _setTokenURI(_tokenId, _tokenURI); } function tokenURI(uint _tokenId) public view override(ERC721, ERC721URIStorage) returns (string memory) { return super.tokenURI(_tokenId); } // *************************** // Promo & price management // *************************** function setPrice(PriceType priceType, uint price) external onlyAdmin { require(price > 0, "Zero price"); if (priceType == PriceType.PROMO) { promoPrice = price; } else if (priceType == PriceType.FULL) { fullPrice = price; } emit TicketPriceChanged(priceType, price); } function setMaxMintAmount(uint amount) external onlyAdmin { maxMint = amount; emit MaxMintAmountChanged(amount); } function setMaxDiscountedMintPerUser(uint mintPerUser) external onlyAdmin { maxDiscountedMintPerUser = mintPerUser; emit MaxDiscountedMintPerUser(mintPerUser); } function isPromo() public view returns (bool) { return (promo.startTime > 0 && block.timestamp >= promo.startTime && block.timestamp <= (promo.startTime + promo.duration)); } // Dynamically gets the token price according to promo, whitelist and msg.sender function getPrice() public view returns (uint) { uint price = fullPrice; if (admins[msg.sender] == true) { price = 0; } else if ((isPromo() || whitelisted[msg.sender] == true) && promos[msg.sender] < maxDiscountedMintPerUser) { price = promoPrice; } return price; } // *************************** // Mint, Gift & Airdrop // *************************** function mint(address to, uint amount) external payable { uint supply = totalSupply(); bool discounted = (getPrice() == promoPrice); require(!paused, "Contract is paused"); require(amount > 0, "Amount is zero"); require(amount <= maxMint, "Amount exceeds max mint"); require(supply + amount <= maxSupply, "Max supply reached"); if (admins[msg.sender] != true) { if (discounted) { require(promos[to] + amount <= maxDiscountedMintPerUser, "Max discounted NFT exceeded for this user"); } require(getPrice().mul(amount) == msg.value, "Ether value sent is not correct"); } for (uint i = 1; i <= amount; i++) { _safeMint(to, supply + i); if(discounted) { promos[to] = promos[to] + 1; } } } function gift(address to, uint amount) external onlyAdmin { uint supply = totalSupply(); require(!paused, "Contract is paused"); require(amount > 0, "Amount is zero"); require(amount <= maxMint, "Amount exceeds max mint"); require(supply + amount <= maxSupply, "Max supply reached"); for (uint i = 1; i <= amount; i++) { _safeMint(to, supply + i); } } function airdrop(address to, uint tokenId) external onlyAdmin { require(!paused, "Contract is paused"); require(to != address(0), "Can't airdrop to a zero address"); safeTransferFrom(msg.sender, to, tokenId); emit Airdropped(to, tokenId); } // *************************** // Game management // *************************** // Main function to draw the roadmap prizes and pay the winners function draw() external payable onlyAdmin { require(!paused, "Contract is paused"); releaseAll(); uint[] memory prizes = consumeRoadmapPrizes(totalSupply()); uint nonce = block.difficulty; for (uint i = 0; i < prizes.length; i++) { uint tokenId = randToken(i, nonce); require(tokenId != 0, "Incorrect tokenId"); address winner = ownerOf(tokenId); require(winner != address(0), "Can't pay a zero address"); pay(payable(winner), (prizes[i] * MILLIETHER)); nonce=nonce^uint(keccak256(abi.encodePacked(winner))); emit Winner(tokenId, winner, prizes[i]); } } // Alternative draw method to choose one random winner with a given prize function drawOne(uint milliEther) external payable onlyAdmin { require(!paused, "Contract is paused"); releaseAll(); uint seed = uint(keccak256(abi.encodePacked(block.coinbase))); uint nonce = uint(keccak256(abi.encodePacked(msg.sender))); uint tokenId = randToken(seed, nonce); require(tokenId != 0, "Incorrect tokenId"); address winner = ownerOf(tokenId); require(winner != address(0), "Can't pay a zero address"); pay(payable(winner), (milliEther * MILLIETHER)); emit Winner(tokenId, winner, milliEther); } // *************************** // Internals // *************************** // Initialize the roadmap function initRoadmap() internal onlyAdmin { roadmap[0] = RoadmapStep(1000,2,22000,1); roadmap[1] = RoadmapStep(2000,3,22000,1); roadmap[2] = RoadmapStep(3000,1,44000,1); roadmap[3] = RoadmapStep(4000,1,44000,1); roadmap[4] = RoadmapStep(5000,50,1100,2); roadmap[5] = RoadmapStep(7000,50,1100,2); roadmap[6] = RoadmapStep(7000,10,11000,1); roadmap[7] = RoadmapStep(10000,1,220000,1); roadmap[8] = RoadmapStep(10000,50,2200,1); } // Consume some prizes according to the roadmap // Rule : winnersCount per week and only one prizeValue same amount at a time. function consumeRoadmapPrizes(uint supply) internal onlyAdmin returns (uint[] memory) { uint index = 0; uint[] memory temp = new uint[](16); for (uint i = 0; i < 9; i++) { isPrizeGiven[roadmap[i].prizeValue] = false; } for (uint i = 0; i < roadmap.length; i++) { if (roadmap[i].supply > supply) { break; } if ((roadmap[i].supply <= supply) && (roadmap[i].winnersCount > 0) && !isPrizeGiven[roadmap[i].prizeValue]) { for (uint j = 0; j < Math.min(roadmap[i].winnersToDraw, roadmap[i].winnersCount); j++) { roadmap[i].winnersCount--; temp[index] = roadmap[i].prizeValue; index++; } isPrizeGiven[roadmap[i].prizeValue] = true; } } uint[] memory prizes = new uint[](index); for (uint i = 0; i < index; i++) { prizes[i] = temp[i]; } return prizes; } // Randomly picks a tokenId function randToken(uint seed, uint nonce) internal view onlyAdmin returns(uint) { uint supply = totalSupply(); if (supply > 0) { uint tokenId = randModulus(supply, seed, nonce); if (tokenId > 0) { return tokenId; } } return 0; } // Pays eth amount to an address function pay(address payable to, uint amount) internal onlyAdmin { require(to != address(0), "Can't pay a zero address"); require(address(this).balance >= amount, "No sufficient fund in contract to pay the address"); (bool sent, bytes memory data) = to.call{value: amount}(""); if (sent) { addToReleased(amount); } require(sent, string(abi.encodePacked("Failed to send Ether:", data))); } // Gets a random number function randModulus(uint max, uint seed, uint nonce) internal view returns(uint) { uint blockNumber = block.number-1; if (block.number>(seed % 256)) { blockNumber=block.number-(seed % 256); } uint rand = uint(keccak256(abi.encodePacked( seed^block.timestamp, block.timestamp, msg.data, nonce, msg.sender, blockhash(blockNumber) ) )) % max; return rand+1; } }
_baseURI
function _baseURI() internal view virtual override returns (string memory) { return baseURI; }
// *************************** // URI management (Reveal) // ***************************
LineComment
v0.8.7+commit.e28d00a7
MIT
ipfs://414d9951eb094e9f3eecc45ff7dcf1c7de317858d1ad8616b1355e70b4b69e2c
{ "func_code_index": [ 6429, 6542 ] }
58,687
MegaMilionsGangstarApes
MegaMilionsGangstarApes.sol
0x3af32fd45224c502469af10e8fff285c18a978bc
Solidity
MegaMilionsGangstarApes
contract MegaMilionsGangstarApes is ERC721, ERC721Enumerable, ERC721URIStorage, ERC2981ContractWideRoyalties, Ownable, PaymentSplitter { using Counters for Counters.Counter; using Strings for uint; using Math for uint; using SafeMath for uint; enum PriceType{ PROMO, FULL } //{ 0, 1 } struct Promo { uint startTime; uint duration; } // Mappings mapping(address => bool) public whitelisted; mapping(address => uint) public promos; mapping(address => bool) public admins; // Default values uint internal constant MILLIETHER = 1e15; //0.001 ETHER = 1,000,000,000,000,000 WEI uint internal promoPrice = 0.1 ether; uint internal fullPrice = 0.3 ether; uint internal maxSupply = 10000; uint internal maxMint = 10; uint internal maxDiscountedMintPerUser = 2; // Vars string private baseURI; bool private paused = false; Promo private promo; // Wallet shares - 50% of revenues shared to team address private DP = 0xcd70Dc892F240D50b7D46CE120dc75c3243E72ab; address private RG = 0x39c34674EEC3AE5F1E9a6Ee899CB85f11a55D990; address private JH = 0xD484E2745d27FA62E6ab0396fd46e0A3E3A00eFc; address private LH = 0xB2CEe0977Bbb0446B358E0Cb3de69e10EdC5eDA3; address private EA = 0x3a4FF805cD9C063f06a0263EEa99F531FAa13B91; address private AG = 0x79f6E63B4D593F3794019A4FEFB52196C602E037; address private JP = 0xd7EE8aF7a902bb208878E50863220e2872b73992; address private MR = 0xaFBC38a36Cb173d75735f3f781e9133939e99888; address private AF = 0x7a2DD031a02Fd595C7BCb0A278A4518daB31AF8d; address private MA = 0xEe3642cb451F6f4ec5C6dd6699fFE69F2D07921E; uint[] private _shares = [ 675, 675, 11250, 6750, 9865, 6750, 7865, 270, 675, 5225 ]; address[] private _team = [ DP, RG, JH, LH, EA, AG, JP, MR, AF, MA ]; // Game struct RoadmapStep { uint64 supply; uint64 winnersCount; uint64 prizeValue; uint64 winnersToDraw; } uint private drawIndex = 0; RoadmapStep[9] private roadmap; mapping(uint => bool) internal isPrizeGiven; // Modifiers modifier onlyAdmin() { require(address(this) == _msgSender() || owner() == _msgSender() || admins[msg.sender], "Not admin"); _; } // Emitters event BaseURIChanged(string tokenBaseURI); event TicketPriceChanged(PriceType priceType, uint price); event MaxMintAmountChanged(uint amount); event MaxDiscountedMintPerUser(uint mintPerUser); event Paused(bool paused); event PromoChanged(uint startTime, uint duration); event Airdropped(address to, uint tokenId); event Winner(uint token, address winner, uint value); event Log(string error); constructor() ERC721("Mega Millions Gangstar Apes", "MMGA") PaymentSplitter(_team, _shares) { //set default admins admins[DP] = true; admins[RG] = true; initRoadmap(); //if ERC2981 supported _setRoyalties(address(this), 1000); //10% } // *************************** // Overrides // *************************** function _beforeTokenTransfer(address from, address to, uint tokenId) internal override(ERC721, ERC721Enumerable) { super._beforeTokenTransfer(from, to, tokenId); } function supportsInterface(bytes4 interfaceId) public view override(ERC721, ERC721Enumerable, ERC2981Base) returns (bool) { return super.supportsInterface(interfaceId); } function _burn(uint _tokenId) internal override(ERC721, ERC721URIStorage) { super._burn(_tokenId); } function burn(uint _tokenId) external onlyAdmin { _burn(_tokenId); maxSupply = maxSupply - 1; } // *************************** // Admins management by owner // *************************** function enableAdmin(address addr) external onlyOwner { admins[addr] = true; } function disableAdmin(address addr) external onlyOwner { require(addr != owner(), "Can't disable owner"); admins[addr] = false; } // *************************** // Release & withdraw // *************************** function releaseAll() public onlyAdmin { for (uint i = 0; i < _team.length; i++) { address member = _team[i]; try this.release(payable(member)) {} catch Error(string memory revertReason) { emit Log(revertReason); } catch (bytes memory returnData) { emit Log(string(returnData)); } } } function withdraw() external onlyAdmin { releaseAll(); pay(payable(owner()), address(this).balance); } // *************************** // Contract management // *************************** function pause(bool newState) external onlyAdmin { paused = newState; emit Paused(newState); } function addWhitelistedUsers(address[] calldata users) external onlyAdmin { for (uint i = 0; i < users.length; i++) { require(users[i] != address(0), "Can't add a zero address"); if (whitelisted[users[i]] == false) { whitelisted[users[i]] = true; } } } function removeWhitelistedUsers(address[] calldata users) external onlyAdmin { for (uint i = 0; i < users.length; i++) { require(users[i] != address(0), "Can't remove a zero address"); if (whitelisted[users[i]] == true) { whitelisted[users[i]] = false; } } } // Duration in seconds function startPromo(uint duration) external onlyAdmin { uint startTime = block.timestamp; promo = Promo(startTime, duration); emit PromoChanged(startTime, duration); } // *************************** // URI management (Reveal) // *************************** function _baseURI() internal view virtual override returns (string memory) { return baseURI; } function setBaseURI(string memory newBaseURI) external onlyAdmin { baseURI = newBaseURI; emit BaseURIChanged(newBaseURI); } function setTokenURI(uint _tokenId, string memory _tokenURI) external onlyAdmin { require(_exists(_tokenId), "URI set of nonexistent token"); _setTokenURI(_tokenId, _tokenURI); } function tokenURI(uint _tokenId) public view override(ERC721, ERC721URIStorage) returns (string memory) { return super.tokenURI(_tokenId); } // *************************** // Promo & price management // *************************** function setPrice(PriceType priceType, uint price) external onlyAdmin { require(price > 0, "Zero price"); if (priceType == PriceType.PROMO) { promoPrice = price; } else if (priceType == PriceType.FULL) { fullPrice = price; } emit TicketPriceChanged(priceType, price); } function setMaxMintAmount(uint amount) external onlyAdmin { maxMint = amount; emit MaxMintAmountChanged(amount); } function setMaxDiscountedMintPerUser(uint mintPerUser) external onlyAdmin { maxDiscountedMintPerUser = mintPerUser; emit MaxDiscountedMintPerUser(mintPerUser); } function isPromo() public view returns (bool) { return (promo.startTime > 0 && block.timestamp >= promo.startTime && block.timestamp <= (promo.startTime + promo.duration)); } // Dynamically gets the token price according to promo, whitelist and msg.sender function getPrice() public view returns (uint) { uint price = fullPrice; if (admins[msg.sender] == true) { price = 0; } else if ((isPromo() || whitelisted[msg.sender] == true) && promos[msg.sender] < maxDiscountedMintPerUser) { price = promoPrice; } return price; } // *************************** // Mint, Gift & Airdrop // *************************** function mint(address to, uint amount) external payable { uint supply = totalSupply(); bool discounted = (getPrice() == promoPrice); require(!paused, "Contract is paused"); require(amount > 0, "Amount is zero"); require(amount <= maxMint, "Amount exceeds max mint"); require(supply + amount <= maxSupply, "Max supply reached"); if (admins[msg.sender] != true) { if (discounted) { require(promos[to] + amount <= maxDiscountedMintPerUser, "Max discounted NFT exceeded for this user"); } require(getPrice().mul(amount) == msg.value, "Ether value sent is not correct"); } for (uint i = 1; i <= amount; i++) { _safeMint(to, supply + i); if(discounted) { promos[to] = promos[to] + 1; } } } function gift(address to, uint amount) external onlyAdmin { uint supply = totalSupply(); require(!paused, "Contract is paused"); require(amount > 0, "Amount is zero"); require(amount <= maxMint, "Amount exceeds max mint"); require(supply + amount <= maxSupply, "Max supply reached"); for (uint i = 1; i <= amount; i++) { _safeMint(to, supply + i); } } function airdrop(address to, uint tokenId) external onlyAdmin { require(!paused, "Contract is paused"); require(to != address(0), "Can't airdrop to a zero address"); safeTransferFrom(msg.sender, to, tokenId); emit Airdropped(to, tokenId); } // *************************** // Game management // *************************** // Main function to draw the roadmap prizes and pay the winners function draw() external payable onlyAdmin { require(!paused, "Contract is paused"); releaseAll(); uint[] memory prizes = consumeRoadmapPrizes(totalSupply()); uint nonce = block.difficulty; for (uint i = 0; i < prizes.length; i++) { uint tokenId = randToken(i, nonce); require(tokenId != 0, "Incorrect tokenId"); address winner = ownerOf(tokenId); require(winner != address(0), "Can't pay a zero address"); pay(payable(winner), (prizes[i] * MILLIETHER)); nonce=nonce^uint(keccak256(abi.encodePacked(winner))); emit Winner(tokenId, winner, prizes[i]); } } // Alternative draw method to choose one random winner with a given prize function drawOne(uint milliEther) external payable onlyAdmin { require(!paused, "Contract is paused"); releaseAll(); uint seed = uint(keccak256(abi.encodePacked(block.coinbase))); uint nonce = uint(keccak256(abi.encodePacked(msg.sender))); uint tokenId = randToken(seed, nonce); require(tokenId != 0, "Incorrect tokenId"); address winner = ownerOf(tokenId); require(winner != address(0), "Can't pay a zero address"); pay(payable(winner), (milliEther * MILLIETHER)); emit Winner(tokenId, winner, milliEther); } // *************************** // Internals // *************************** // Initialize the roadmap function initRoadmap() internal onlyAdmin { roadmap[0] = RoadmapStep(1000,2,22000,1); roadmap[1] = RoadmapStep(2000,3,22000,1); roadmap[2] = RoadmapStep(3000,1,44000,1); roadmap[3] = RoadmapStep(4000,1,44000,1); roadmap[4] = RoadmapStep(5000,50,1100,2); roadmap[5] = RoadmapStep(7000,50,1100,2); roadmap[6] = RoadmapStep(7000,10,11000,1); roadmap[7] = RoadmapStep(10000,1,220000,1); roadmap[8] = RoadmapStep(10000,50,2200,1); } // Consume some prizes according to the roadmap // Rule : winnersCount per week and only one prizeValue same amount at a time. function consumeRoadmapPrizes(uint supply) internal onlyAdmin returns (uint[] memory) { uint index = 0; uint[] memory temp = new uint[](16); for (uint i = 0; i < 9; i++) { isPrizeGiven[roadmap[i].prizeValue] = false; } for (uint i = 0; i < roadmap.length; i++) { if (roadmap[i].supply > supply) { break; } if ((roadmap[i].supply <= supply) && (roadmap[i].winnersCount > 0) && !isPrizeGiven[roadmap[i].prizeValue]) { for (uint j = 0; j < Math.min(roadmap[i].winnersToDraw, roadmap[i].winnersCount); j++) { roadmap[i].winnersCount--; temp[index] = roadmap[i].prizeValue; index++; } isPrizeGiven[roadmap[i].prizeValue] = true; } } uint[] memory prizes = new uint[](index); for (uint i = 0; i < index; i++) { prizes[i] = temp[i]; } return prizes; } // Randomly picks a tokenId function randToken(uint seed, uint nonce) internal view onlyAdmin returns(uint) { uint supply = totalSupply(); if (supply > 0) { uint tokenId = randModulus(supply, seed, nonce); if (tokenId > 0) { return tokenId; } } return 0; } // Pays eth amount to an address function pay(address payable to, uint amount) internal onlyAdmin { require(to != address(0), "Can't pay a zero address"); require(address(this).balance >= amount, "No sufficient fund in contract to pay the address"); (bool sent, bytes memory data) = to.call{value: amount}(""); if (sent) { addToReleased(amount); } require(sent, string(abi.encodePacked("Failed to send Ether:", data))); } // Gets a random number function randModulus(uint max, uint seed, uint nonce) internal view returns(uint) { uint blockNumber = block.number-1; if (block.number>(seed % 256)) { blockNumber=block.number-(seed % 256); } uint rand = uint(keccak256(abi.encodePacked( seed^block.timestamp, block.timestamp, msg.data, nonce, msg.sender, blockhash(blockNumber) ) )) % max; return rand+1; } }
setPrice
function setPrice(PriceType priceType, uint price) external onlyAdmin { require(price > 0, "Zero price"); if (priceType == PriceType.PROMO) { promoPrice = price; } else if (priceType == PriceType.FULL) { fullPrice = price; } emit TicketPriceChanged(priceType, price); }
// *************************** // Promo & price management // ***************************
LineComment
v0.8.7+commit.e28d00a7
MIT
ipfs://414d9951eb094e9f3eecc45ff7dcf1c7de317858d1ad8616b1355e70b4b69e2c
{ "func_code_index": [ 7220, 7570 ] }
58,688
MegaMilionsGangstarApes
MegaMilionsGangstarApes.sol
0x3af32fd45224c502469af10e8fff285c18a978bc
Solidity
MegaMilionsGangstarApes
contract MegaMilionsGangstarApes is ERC721, ERC721Enumerable, ERC721URIStorage, ERC2981ContractWideRoyalties, Ownable, PaymentSplitter { using Counters for Counters.Counter; using Strings for uint; using Math for uint; using SafeMath for uint; enum PriceType{ PROMO, FULL } //{ 0, 1 } struct Promo { uint startTime; uint duration; } // Mappings mapping(address => bool) public whitelisted; mapping(address => uint) public promos; mapping(address => bool) public admins; // Default values uint internal constant MILLIETHER = 1e15; //0.001 ETHER = 1,000,000,000,000,000 WEI uint internal promoPrice = 0.1 ether; uint internal fullPrice = 0.3 ether; uint internal maxSupply = 10000; uint internal maxMint = 10; uint internal maxDiscountedMintPerUser = 2; // Vars string private baseURI; bool private paused = false; Promo private promo; // Wallet shares - 50% of revenues shared to team address private DP = 0xcd70Dc892F240D50b7D46CE120dc75c3243E72ab; address private RG = 0x39c34674EEC3AE5F1E9a6Ee899CB85f11a55D990; address private JH = 0xD484E2745d27FA62E6ab0396fd46e0A3E3A00eFc; address private LH = 0xB2CEe0977Bbb0446B358E0Cb3de69e10EdC5eDA3; address private EA = 0x3a4FF805cD9C063f06a0263EEa99F531FAa13B91; address private AG = 0x79f6E63B4D593F3794019A4FEFB52196C602E037; address private JP = 0xd7EE8aF7a902bb208878E50863220e2872b73992; address private MR = 0xaFBC38a36Cb173d75735f3f781e9133939e99888; address private AF = 0x7a2DD031a02Fd595C7BCb0A278A4518daB31AF8d; address private MA = 0xEe3642cb451F6f4ec5C6dd6699fFE69F2D07921E; uint[] private _shares = [ 675, 675, 11250, 6750, 9865, 6750, 7865, 270, 675, 5225 ]; address[] private _team = [ DP, RG, JH, LH, EA, AG, JP, MR, AF, MA ]; // Game struct RoadmapStep { uint64 supply; uint64 winnersCount; uint64 prizeValue; uint64 winnersToDraw; } uint private drawIndex = 0; RoadmapStep[9] private roadmap; mapping(uint => bool) internal isPrizeGiven; // Modifiers modifier onlyAdmin() { require(address(this) == _msgSender() || owner() == _msgSender() || admins[msg.sender], "Not admin"); _; } // Emitters event BaseURIChanged(string tokenBaseURI); event TicketPriceChanged(PriceType priceType, uint price); event MaxMintAmountChanged(uint amount); event MaxDiscountedMintPerUser(uint mintPerUser); event Paused(bool paused); event PromoChanged(uint startTime, uint duration); event Airdropped(address to, uint tokenId); event Winner(uint token, address winner, uint value); event Log(string error); constructor() ERC721("Mega Millions Gangstar Apes", "MMGA") PaymentSplitter(_team, _shares) { //set default admins admins[DP] = true; admins[RG] = true; initRoadmap(); //if ERC2981 supported _setRoyalties(address(this), 1000); //10% } // *************************** // Overrides // *************************** function _beforeTokenTransfer(address from, address to, uint tokenId) internal override(ERC721, ERC721Enumerable) { super._beforeTokenTransfer(from, to, tokenId); } function supportsInterface(bytes4 interfaceId) public view override(ERC721, ERC721Enumerable, ERC2981Base) returns (bool) { return super.supportsInterface(interfaceId); } function _burn(uint _tokenId) internal override(ERC721, ERC721URIStorage) { super._burn(_tokenId); } function burn(uint _tokenId) external onlyAdmin { _burn(_tokenId); maxSupply = maxSupply - 1; } // *************************** // Admins management by owner // *************************** function enableAdmin(address addr) external onlyOwner { admins[addr] = true; } function disableAdmin(address addr) external onlyOwner { require(addr != owner(), "Can't disable owner"); admins[addr] = false; } // *************************** // Release & withdraw // *************************** function releaseAll() public onlyAdmin { for (uint i = 0; i < _team.length; i++) { address member = _team[i]; try this.release(payable(member)) {} catch Error(string memory revertReason) { emit Log(revertReason); } catch (bytes memory returnData) { emit Log(string(returnData)); } } } function withdraw() external onlyAdmin { releaseAll(); pay(payable(owner()), address(this).balance); } // *************************** // Contract management // *************************** function pause(bool newState) external onlyAdmin { paused = newState; emit Paused(newState); } function addWhitelistedUsers(address[] calldata users) external onlyAdmin { for (uint i = 0; i < users.length; i++) { require(users[i] != address(0), "Can't add a zero address"); if (whitelisted[users[i]] == false) { whitelisted[users[i]] = true; } } } function removeWhitelistedUsers(address[] calldata users) external onlyAdmin { for (uint i = 0; i < users.length; i++) { require(users[i] != address(0), "Can't remove a zero address"); if (whitelisted[users[i]] == true) { whitelisted[users[i]] = false; } } } // Duration in seconds function startPromo(uint duration) external onlyAdmin { uint startTime = block.timestamp; promo = Promo(startTime, duration); emit PromoChanged(startTime, duration); } // *************************** // URI management (Reveal) // *************************** function _baseURI() internal view virtual override returns (string memory) { return baseURI; } function setBaseURI(string memory newBaseURI) external onlyAdmin { baseURI = newBaseURI; emit BaseURIChanged(newBaseURI); } function setTokenURI(uint _tokenId, string memory _tokenURI) external onlyAdmin { require(_exists(_tokenId), "URI set of nonexistent token"); _setTokenURI(_tokenId, _tokenURI); } function tokenURI(uint _tokenId) public view override(ERC721, ERC721URIStorage) returns (string memory) { return super.tokenURI(_tokenId); } // *************************** // Promo & price management // *************************** function setPrice(PriceType priceType, uint price) external onlyAdmin { require(price > 0, "Zero price"); if (priceType == PriceType.PROMO) { promoPrice = price; } else if (priceType == PriceType.FULL) { fullPrice = price; } emit TicketPriceChanged(priceType, price); } function setMaxMintAmount(uint amount) external onlyAdmin { maxMint = amount; emit MaxMintAmountChanged(amount); } function setMaxDiscountedMintPerUser(uint mintPerUser) external onlyAdmin { maxDiscountedMintPerUser = mintPerUser; emit MaxDiscountedMintPerUser(mintPerUser); } function isPromo() public view returns (bool) { return (promo.startTime > 0 && block.timestamp >= promo.startTime && block.timestamp <= (promo.startTime + promo.duration)); } // Dynamically gets the token price according to promo, whitelist and msg.sender function getPrice() public view returns (uint) { uint price = fullPrice; if (admins[msg.sender] == true) { price = 0; } else if ((isPromo() || whitelisted[msg.sender] == true) && promos[msg.sender] < maxDiscountedMintPerUser) { price = promoPrice; } return price; } // *************************** // Mint, Gift & Airdrop // *************************** function mint(address to, uint amount) external payable { uint supply = totalSupply(); bool discounted = (getPrice() == promoPrice); require(!paused, "Contract is paused"); require(amount > 0, "Amount is zero"); require(amount <= maxMint, "Amount exceeds max mint"); require(supply + amount <= maxSupply, "Max supply reached"); if (admins[msg.sender] != true) { if (discounted) { require(promos[to] + amount <= maxDiscountedMintPerUser, "Max discounted NFT exceeded for this user"); } require(getPrice().mul(amount) == msg.value, "Ether value sent is not correct"); } for (uint i = 1; i <= amount; i++) { _safeMint(to, supply + i); if(discounted) { promos[to] = promos[to] + 1; } } } function gift(address to, uint amount) external onlyAdmin { uint supply = totalSupply(); require(!paused, "Contract is paused"); require(amount > 0, "Amount is zero"); require(amount <= maxMint, "Amount exceeds max mint"); require(supply + amount <= maxSupply, "Max supply reached"); for (uint i = 1; i <= amount; i++) { _safeMint(to, supply + i); } } function airdrop(address to, uint tokenId) external onlyAdmin { require(!paused, "Contract is paused"); require(to != address(0), "Can't airdrop to a zero address"); safeTransferFrom(msg.sender, to, tokenId); emit Airdropped(to, tokenId); } // *************************** // Game management // *************************** // Main function to draw the roadmap prizes and pay the winners function draw() external payable onlyAdmin { require(!paused, "Contract is paused"); releaseAll(); uint[] memory prizes = consumeRoadmapPrizes(totalSupply()); uint nonce = block.difficulty; for (uint i = 0; i < prizes.length; i++) { uint tokenId = randToken(i, nonce); require(tokenId != 0, "Incorrect tokenId"); address winner = ownerOf(tokenId); require(winner != address(0), "Can't pay a zero address"); pay(payable(winner), (prizes[i] * MILLIETHER)); nonce=nonce^uint(keccak256(abi.encodePacked(winner))); emit Winner(tokenId, winner, prizes[i]); } } // Alternative draw method to choose one random winner with a given prize function drawOne(uint milliEther) external payable onlyAdmin { require(!paused, "Contract is paused"); releaseAll(); uint seed = uint(keccak256(abi.encodePacked(block.coinbase))); uint nonce = uint(keccak256(abi.encodePacked(msg.sender))); uint tokenId = randToken(seed, nonce); require(tokenId != 0, "Incorrect tokenId"); address winner = ownerOf(tokenId); require(winner != address(0), "Can't pay a zero address"); pay(payable(winner), (milliEther * MILLIETHER)); emit Winner(tokenId, winner, milliEther); } // *************************** // Internals // *************************** // Initialize the roadmap function initRoadmap() internal onlyAdmin { roadmap[0] = RoadmapStep(1000,2,22000,1); roadmap[1] = RoadmapStep(2000,3,22000,1); roadmap[2] = RoadmapStep(3000,1,44000,1); roadmap[3] = RoadmapStep(4000,1,44000,1); roadmap[4] = RoadmapStep(5000,50,1100,2); roadmap[5] = RoadmapStep(7000,50,1100,2); roadmap[6] = RoadmapStep(7000,10,11000,1); roadmap[7] = RoadmapStep(10000,1,220000,1); roadmap[8] = RoadmapStep(10000,50,2200,1); } // Consume some prizes according to the roadmap // Rule : winnersCount per week and only one prizeValue same amount at a time. function consumeRoadmapPrizes(uint supply) internal onlyAdmin returns (uint[] memory) { uint index = 0; uint[] memory temp = new uint[](16); for (uint i = 0; i < 9; i++) { isPrizeGiven[roadmap[i].prizeValue] = false; } for (uint i = 0; i < roadmap.length; i++) { if (roadmap[i].supply > supply) { break; } if ((roadmap[i].supply <= supply) && (roadmap[i].winnersCount > 0) && !isPrizeGiven[roadmap[i].prizeValue]) { for (uint j = 0; j < Math.min(roadmap[i].winnersToDraw, roadmap[i].winnersCount); j++) { roadmap[i].winnersCount--; temp[index] = roadmap[i].prizeValue; index++; } isPrizeGiven[roadmap[i].prizeValue] = true; } } uint[] memory prizes = new uint[](index); for (uint i = 0; i < index; i++) { prizes[i] = temp[i]; } return prizes; } // Randomly picks a tokenId function randToken(uint seed, uint nonce) internal view onlyAdmin returns(uint) { uint supply = totalSupply(); if (supply > 0) { uint tokenId = randModulus(supply, seed, nonce); if (tokenId > 0) { return tokenId; } } return 0; } // Pays eth amount to an address function pay(address payable to, uint amount) internal onlyAdmin { require(to != address(0), "Can't pay a zero address"); require(address(this).balance >= amount, "No sufficient fund in contract to pay the address"); (bool sent, bytes memory data) = to.call{value: amount}(""); if (sent) { addToReleased(amount); } require(sent, string(abi.encodePacked("Failed to send Ether:", data))); } // Gets a random number function randModulus(uint max, uint seed, uint nonce) internal view returns(uint) { uint blockNumber = block.number-1; if (block.number>(seed % 256)) { blockNumber=block.number-(seed % 256); } uint rand = uint(keccak256(abi.encodePacked( seed^block.timestamp, block.timestamp, msg.data, nonce, msg.sender, blockhash(blockNumber) ) )) % max; return rand+1; } }
getPrice
function getPrice() public view returns (uint) { uint price = fullPrice; if (admins[msg.sender] == true) { rice = 0; else if ((isPromo() || whitelisted[msg.sender] == true) && promos[msg.sender] < maxDiscountedMintPerUser) { price = promoPrice; } return price; }
// Dynamically gets the token price according to promo, whitelist and msg.sender
LineComment
v0.8.7+commit.e28d00a7
MIT
ipfs://414d9951eb094e9f3eecc45ff7dcf1c7de317858d1ad8616b1355e70b4b69e2c
{ "func_code_index": [ 8242, 8595 ] }
58,689
MegaMilionsGangstarApes
MegaMilionsGangstarApes.sol
0x3af32fd45224c502469af10e8fff285c18a978bc
Solidity
MegaMilionsGangstarApes
contract MegaMilionsGangstarApes is ERC721, ERC721Enumerable, ERC721URIStorage, ERC2981ContractWideRoyalties, Ownable, PaymentSplitter { using Counters for Counters.Counter; using Strings for uint; using Math for uint; using SafeMath for uint; enum PriceType{ PROMO, FULL } //{ 0, 1 } struct Promo { uint startTime; uint duration; } // Mappings mapping(address => bool) public whitelisted; mapping(address => uint) public promos; mapping(address => bool) public admins; // Default values uint internal constant MILLIETHER = 1e15; //0.001 ETHER = 1,000,000,000,000,000 WEI uint internal promoPrice = 0.1 ether; uint internal fullPrice = 0.3 ether; uint internal maxSupply = 10000; uint internal maxMint = 10; uint internal maxDiscountedMintPerUser = 2; // Vars string private baseURI; bool private paused = false; Promo private promo; // Wallet shares - 50% of revenues shared to team address private DP = 0xcd70Dc892F240D50b7D46CE120dc75c3243E72ab; address private RG = 0x39c34674EEC3AE5F1E9a6Ee899CB85f11a55D990; address private JH = 0xD484E2745d27FA62E6ab0396fd46e0A3E3A00eFc; address private LH = 0xB2CEe0977Bbb0446B358E0Cb3de69e10EdC5eDA3; address private EA = 0x3a4FF805cD9C063f06a0263EEa99F531FAa13B91; address private AG = 0x79f6E63B4D593F3794019A4FEFB52196C602E037; address private JP = 0xd7EE8aF7a902bb208878E50863220e2872b73992; address private MR = 0xaFBC38a36Cb173d75735f3f781e9133939e99888; address private AF = 0x7a2DD031a02Fd595C7BCb0A278A4518daB31AF8d; address private MA = 0xEe3642cb451F6f4ec5C6dd6699fFE69F2D07921E; uint[] private _shares = [ 675, 675, 11250, 6750, 9865, 6750, 7865, 270, 675, 5225 ]; address[] private _team = [ DP, RG, JH, LH, EA, AG, JP, MR, AF, MA ]; // Game struct RoadmapStep { uint64 supply; uint64 winnersCount; uint64 prizeValue; uint64 winnersToDraw; } uint private drawIndex = 0; RoadmapStep[9] private roadmap; mapping(uint => bool) internal isPrizeGiven; // Modifiers modifier onlyAdmin() { require(address(this) == _msgSender() || owner() == _msgSender() || admins[msg.sender], "Not admin"); _; } // Emitters event BaseURIChanged(string tokenBaseURI); event TicketPriceChanged(PriceType priceType, uint price); event MaxMintAmountChanged(uint amount); event MaxDiscountedMintPerUser(uint mintPerUser); event Paused(bool paused); event PromoChanged(uint startTime, uint duration); event Airdropped(address to, uint tokenId); event Winner(uint token, address winner, uint value); event Log(string error); constructor() ERC721("Mega Millions Gangstar Apes", "MMGA") PaymentSplitter(_team, _shares) { //set default admins admins[DP] = true; admins[RG] = true; initRoadmap(); //if ERC2981 supported _setRoyalties(address(this), 1000); //10% } // *************************** // Overrides // *************************** function _beforeTokenTransfer(address from, address to, uint tokenId) internal override(ERC721, ERC721Enumerable) { super._beforeTokenTransfer(from, to, tokenId); } function supportsInterface(bytes4 interfaceId) public view override(ERC721, ERC721Enumerable, ERC2981Base) returns (bool) { return super.supportsInterface(interfaceId); } function _burn(uint _tokenId) internal override(ERC721, ERC721URIStorage) { super._burn(_tokenId); } function burn(uint _tokenId) external onlyAdmin { _burn(_tokenId); maxSupply = maxSupply - 1; } // *************************** // Admins management by owner // *************************** function enableAdmin(address addr) external onlyOwner { admins[addr] = true; } function disableAdmin(address addr) external onlyOwner { require(addr != owner(), "Can't disable owner"); admins[addr] = false; } // *************************** // Release & withdraw // *************************** function releaseAll() public onlyAdmin { for (uint i = 0; i < _team.length; i++) { address member = _team[i]; try this.release(payable(member)) {} catch Error(string memory revertReason) { emit Log(revertReason); } catch (bytes memory returnData) { emit Log(string(returnData)); } } } function withdraw() external onlyAdmin { releaseAll(); pay(payable(owner()), address(this).balance); } // *************************** // Contract management // *************************** function pause(bool newState) external onlyAdmin { paused = newState; emit Paused(newState); } function addWhitelistedUsers(address[] calldata users) external onlyAdmin { for (uint i = 0; i < users.length; i++) { require(users[i] != address(0), "Can't add a zero address"); if (whitelisted[users[i]] == false) { whitelisted[users[i]] = true; } } } function removeWhitelistedUsers(address[] calldata users) external onlyAdmin { for (uint i = 0; i < users.length; i++) { require(users[i] != address(0), "Can't remove a zero address"); if (whitelisted[users[i]] == true) { whitelisted[users[i]] = false; } } } // Duration in seconds function startPromo(uint duration) external onlyAdmin { uint startTime = block.timestamp; promo = Promo(startTime, duration); emit PromoChanged(startTime, duration); } // *************************** // URI management (Reveal) // *************************** function _baseURI() internal view virtual override returns (string memory) { return baseURI; } function setBaseURI(string memory newBaseURI) external onlyAdmin { baseURI = newBaseURI; emit BaseURIChanged(newBaseURI); } function setTokenURI(uint _tokenId, string memory _tokenURI) external onlyAdmin { require(_exists(_tokenId), "URI set of nonexistent token"); _setTokenURI(_tokenId, _tokenURI); } function tokenURI(uint _tokenId) public view override(ERC721, ERC721URIStorage) returns (string memory) { return super.tokenURI(_tokenId); } // *************************** // Promo & price management // *************************** function setPrice(PriceType priceType, uint price) external onlyAdmin { require(price > 0, "Zero price"); if (priceType == PriceType.PROMO) { promoPrice = price; } else if (priceType == PriceType.FULL) { fullPrice = price; } emit TicketPriceChanged(priceType, price); } function setMaxMintAmount(uint amount) external onlyAdmin { maxMint = amount; emit MaxMintAmountChanged(amount); } function setMaxDiscountedMintPerUser(uint mintPerUser) external onlyAdmin { maxDiscountedMintPerUser = mintPerUser; emit MaxDiscountedMintPerUser(mintPerUser); } function isPromo() public view returns (bool) { return (promo.startTime > 0 && block.timestamp >= promo.startTime && block.timestamp <= (promo.startTime + promo.duration)); } // Dynamically gets the token price according to promo, whitelist and msg.sender function getPrice() public view returns (uint) { uint price = fullPrice; if (admins[msg.sender] == true) { price = 0; } else if ((isPromo() || whitelisted[msg.sender] == true) && promos[msg.sender] < maxDiscountedMintPerUser) { price = promoPrice; } return price; } // *************************** // Mint, Gift & Airdrop // *************************** function mint(address to, uint amount) external payable { uint supply = totalSupply(); bool discounted = (getPrice() == promoPrice); require(!paused, "Contract is paused"); require(amount > 0, "Amount is zero"); require(amount <= maxMint, "Amount exceeds max mint"); require(supply + amount <= maxSupply, "Max supply reached"); if (admins[msg.sender] != true) { if (discounted) { require(promos[to] + amount <= maxDiscountedMintPerUser, "Max discounted NFT exceeded for this user"); } require(getPrice().mul(amount) == msg.value, "Ether value sent is not correct"); } for (uint i = 1; i <= amount; i++) { _safeMint(to, supply + i); if(discounted) { promos[to] = promos[to] + 1; } } } function gift(address to, uint amount) external onlyAdmin { uint supply = totalSupply(); require(!paused, "Contract is paused"); require(amount > 0, "Amount is zero"); require(amount <= maxMint, "Amount exceeds max mint"); require(supply + amount <= maxSupply, "Max supply reached"); for (uint i = 1; i <= amount; i++) { _safeMint(to, supply + i); } } function airdrop(address to, uint tokenId) external onlyAdmin { require(!paused, "Contract is paused"); require(to != address(0), "Can't airdrop to a zero address"); safeTransferFrom(msg.sender, to, tokenId); emit Airdropped(to, tokenId); } // *************************** // Game management // *************************** // Main function to draw the roadmap prizes and pay the winners function draw() external payable onlyAdmin { require(!paused, "Contract is paused"); releaseAll(); uint[] memory prizes = consumeRoadmapPrizes(totalSupply()); uint nonce = block.difficulty; for (uint i = 0; i < prizes.length; i++) { uint tokenId = randToken(i, nonce); require(tokenId != 0, "Incorrect tokenId"); address winner = ownerOf(tokenId); require(winner != address(0), "Can't pay a zero address"); pay(payable(winner), (prizes[i] * MILLIETHER)); nonce=nonce^uint(keccak256(abi.encodePacked(winner))); emit Winner(tokenId, winner, prizes[i]); } } // Alternative draw method to choose one random winner with a given prize function drawOne(uint milliEther) external payable onlyAdmin { require(!paused, "Contract is paused"); releaseAll(); uint seed = uint(keccak256(abi.encodePacked(block.coinbase))); uint nonce = uint(keccak256(abi.encodePacked(msg.sender))); uint tokenId = randToken(seed, nonce); require(tokenId != 0, "Incorrect tokenId"); address winner = ownerOf(tokenId); require(winner != address(0), "Can't pay a zero address"); pay(payable(winner), (milliEther * MILLIETHER)); emit Winner(tokenId, winner, milliEther); } // *************************** // Internals // *************************** // Initialize the roadmap function initRoadmap() internal onlyAdmin { roadmap[0] = RoadmapStep(1000,2,22000,1); roadmap[1] = RoadmapStep(2000,3,22000,1); roadmap[2] = RoadmapStep(3000,1,44000,1); roadmap[3] = RoadmapStep(4000,1,44000,1); roadmap[4] = RoadmapStep(5000,50,1100,2); roadmap[5] = RoadmapStep(7000,50,1100,2); roadmap[6] = RoadmapStep(7000,10,11000,1); roadmap[7] = RoadmapStep(10000,1,220000,1); roadmap[8] = RoadmapStep(10000,50,2200,1); } // Consume some prizes according to the roadmap // Rule : winnersCount per week and only one prizeValue same amount at a time. function consumeRoadmapPrizes(uint supply) internal onlyAdmin returns (uint[] memory) { uint index = 0; uint[] memory temp = new uint[](16); for (uint i = 0; i < 9; i++) { isPrizeGiven[roadmap[i].prizeValue] = false; } for (uint i = 0; i < roadmap.length; i++) { if (roadmap[i].supply > supply) { break; } if ((roadmap[i].supply <= supply) && (roadmap[i].winnersCount > 0) && !isPrizeGiven[roadmap[i].prizeValue]) { for (uint j = 0; j < Math.min(roadmap[i].winnersToDraw, roadmap[i].winnersCount); j++) { roadmap[i].winnersCount--; temp[index] = roadmap[i].prizeValue; index++; } isPrizeGiven[roadmap[i].prizeValue] = true; } } uint[] memory prizes = new uint[](index); for (uint i = 0; i < index; i++) { prizes[i] = temp[i]; } return prizes; } // Randomly picks a tokenId function randToken(uint seed, uint nonce) internal view onlyAdmin returns(uint) { uint supply = totalSupply(); if (supply > 0) { uint tokenId = randModulus(supply, seed, nonce); if (tokenId > 0) { return tokenId; } } return 0; } // Pays eth amount to an address function pay(address payable to, uint amount) internal onlyAdmin { require(to != address(0), "Can't pay a zero address"); require(address(this).balance >= amount, "No sufficient fund in contract to pay the address"); (bool sent, bytes memory data) = to.call{value: amount}(""); if (sent) { addToReleased(amount); } require(sent, string(abi.encodePacked("Failed to send Ether:", data))); } // Gets a random number function randModulus(uint max, uint seed, uint nonce) internal view returns(uint) { uint blockNumber = block.number-1; if (block.number>(seed % 256)) { blockNumber=block.number-(seed % 256); } uint rand = uint(keccak256(abi.encodePacked( seed^block.timestamp, block.timestamp, msg.data, nonce, msg.sender, blockhash(blockNumber) ) )) % max; return rand+1; } }
mint
function mint(address to, uint amount) external payable { uint supply = totalSupply(); bool discounted = (getPrice() == promoPrice); require(!paused, "Contract is paused"); require(amount > 0, "Amount is zero"); require(amount <= maxMint, "Amount exceeds max mint"); require(supply + amount <= maxSupply, "Max supply reached"); if (admins[msg.sender] != true) { if (discounted) { require(promos[to] + amount <= maxDiscountedMintPerUser, "Max discounted NFT exceeded for this user"); } require(getPrice().mul(amount) == msg.value, "Ether value sent is not correct"); } for (uint i = 1; i <= amount; i++) { _safeMint(to, supply + i); if(discounted) { promos[to] = promos[to] + 1; } } }
// *************************** // Mint, Gift & Airdrop // ***************************
LineComment
v0.8.7+commit.e28d00a7
MIT
ipfs://414d9951eb094e9f3eecc45ff7dcf1c7de317858d1ad8616b1355e70b4b69e2c
{ "func_code_index": [ 8704, 9599 ] }
58,690
MegaMilionsGangstarApes
MegaMilionsGangstarApes.sol
0x3af32fd45224c502469af10e8fff285c18a978bc
Solidity
MegaMilionsGangstarApes
contract MegaMilionsGangstarApes is ERC721, ERC721Enumerable, ERC721URIStorage, ERC2981ContractWideRoyalties, Ownable, PaymentSplitter { using Counters for Counters.Counter; using Strings for uint; using Math for uint; using SafeMath for uint; enum PriceType{ PROMO, FULL } //{ 0, 1 } struct Promo { uint startTime; uint duration; } // Mappings mapping(address => bool) public whitelisted; mapping(address => uint) public promos; mapping(address => bool) public admins; // Default values uint internal constant MILLIETHER = 1e15; //0.001 ETHER = 1,000,000,000,000,000 WEI uint internal promoPrice = 0.1 ether; uint internal fullPrice = 0.3 ether; uint internal maxSupply = 10000; uint internal maxMint = 10; uint internal maxDiscountedMintPerUser = 2; // Vars string private baseURI; bool private paused = false; Promo private promo; // Wallet shares - 50% of revenues shared to team address private DP = 0xcd70Dc892F240D50b7D46CE120dc75c3243E72ab; address private RG = 0x39c34674EEC3AE5F1E9a6Ee899CB85f11a55D990; address private JH = 0xD484E2745d27FA62E6ab0396fd46e0A3E3A00eFc; address private LH = 0xB2CEe0977Bbb0446B358E0Cb3de69e10EdC5eDA3; address private EA = 0x3a4FF805cD9C063f06a0263EEa99F531FAa13B91; address private AG = 0x79f6E63B4D593F3794019A4FEFB52196C602E037; address private JP = 0xd7EE8aF7a902bb208878E50863220e2872b73992; address private MR = 0xaFBC38a36Cb173d75735f3f781e9133939e99888; address private AF = 0x7a2DD031a02Fd595C7BCb0A278A4518daB31AF8d; address private MA = 0xEe3642cb451F6f4ec5C6dd6699fFE69F2D07921E; uint[] private _shares = [ 675, 675, 11250, 6750, 9865, 6750, 7865, 270, 675, 5225 ]; address[] private _team = [ DP, RG, JH, LH, EA, AG, JP, MR, AF, MA ]; // Game struct RoadmapStep { uint64 supply; uint64 winnersCount; uint64 prizeValue; uint64 winnersToDraw; } uint private drawIndex = 0; RoadmapStep[9] private roadmap; mapping(uint => bool) internal isPrizeGiven; // Modifiers modifier onlyAdmin() { require(address(this) == _msgSender() || owner() == _msgSender() || admins[msg.sender], "Not admin"); _; } // Emitters event BaseURIChanged(string tokenBaseURI); event TicketPriceChanged(PriceType priceType, uint price); event MaxMintAmountChanged(uint amount); event MaxDiscountedMintPerUser(uint mintPerUser); event Paused(bool paused); event PromoChanged(uint startTime, uint duration); event Airdropped(address to, uint tokenId); event Winner(uint token, address winner, uint value); event Log(string error); constructor() ERC721("Mega Millions Gangstar Apes", "MMGA") PaymentSplitter(_team, _shares) { //set default admins admins[DP] = true; admins[RG] = true; initRoadmap(); //if ERC2981 supported _setRoyalties(address(this), 1000); //10% } // *************************** // Overrides // *************************** function _beforeTokenTransfer(address from, address to, uint tokenId) internal override(ERC721, ERC721Enumerable) { super._beforeTokenTransfer(from, to, tokenId); } function supportsInterface(bytes4 interfaceId) public view override(ERC721, ERC721Enumerable, ERC2981Base) returns (bool) { return super.supportsInterface(interfaceId); } function _burn(uint _tokenId) internal override(ERC721, ERC721URIStorage) { super._burn(_tokenId); } function burn(uint _tokenId) external onlyAdmin { _burn(_tokenId); maxSupply = maxSupply - 1; } // *************************** // Admins management by owner // *************************** function enableAdmin(address addr) external onlyOwner { admins[addr] = true; } function disableAdmin(address addr) external onlyOwner { require(addr != owner(), "Can't disable owner"); admins[addr] = false; } // *************************** // Release & withdraw // *************************** function releaseAll() public onlyAdmin { for (uint i = 0; i < _team.length; i++) { address member = _team[i]; try this.release(payable(member)) {} catch Error(string memory revertReason) { emit Log(revertReason); } catch (bytes memory returnData) { emit Log(string(returnData)); } } } function withdraw() external onlyAdmin { releaseAll(); pay(payable(owner()), address(this).balance); } // *************************** // Contract management // *************************** function pause(bool newState) external onlyAdmin { paused = newState; emit Paused(newState); } function addWhitelistedUsers(address[] calldata users) external onlyAdmin { for (uint i = 0; i < users.length; i++) { require(users[i] != address(0), "Can't add a zero address"); if (whitelisted[users[i]] == false) { whitelisted[users[i]] = true; } } } function removeWhitelistedUsers(address[] calldata users) external onlyAdmin { for (uint i = 0; i < users.length; i++) { require(users[i] != address(0), "Can't remove a zero address"); if (whitelisted[users[i]] == true) { whitelisted[users[i]] = false; } } } // Duration in seconds function startPromo(uint duration) external onlyAdmin { uint startTime = block.timestamp; promo = Promo(startTime, duration); emit PromoChanged(startTime, duration); } // *************************** // URI management (Reveal) // *************************** function _baseURI() internal view virtual override returns (string memory) { return baseURI; } function setBaseURI(string memory newBaseURI) external onlyAdmin { baseURI = newBaseURI; emit BaseURIChanged(newBaseURI); } function setTokenURI(uint _tokenId, string memory _tokenURI) external onlyAdmin { require(_exists(_tokenId), "URI set of nonexistent token"); _setTokenURI(_tokenId, _tokenURI); } function tokenURI(uint _tokenId) public view override(ERC721, ERC721URIStorage) returns (string memory) { return super.tokenURI(_tokenId); } // *************************** // Promo & price management // *************************** function setPrice(PriceType priceType, uint price) external onlyAdmin { require(price > 0, "Zero price"); if (priceType == PriceType.PROMO) { promoPrice = price; } else if (priceType == PriceType.FULL) { fullPrice = price; } emit TicketPriceChanged(priceType, price); } function setMaxMintAmount(uint amount) external onlyAdmin { maxMint = amount; emit MaxMintAmountChanged(amount); } function setMaxDiscountedMintPerUser(uint mintPerUser) external onlyAdmin { maxDiscountedMintPerUser = mintPerUser; emit MaxDiscountedMintPerUser(mintPerUser); } function isPromo() public view returns (bool) { return (promo.startTime > 0 && block.timestamp >= promo.startTime && block.timestamp <= (promo.startTime + promo.duration)); } // Dynamically gets the token price according to promo, whitelist and msg.sender function getPrice() public view returns (uint) { uint price = fullPrice; if (admins[msg.sender] == true) { price = 0; } else if ((isPromo() || whitelisted[msg.sender] == true) && promos[msg.sender] < maxDiscountedMintPerUser) { price = promoPrice; } return price; } // *************************** // Mint, Gift & Airdrop // *************************** function mint(address to, uint amount) external payable { uint supply = totalSupply(); bool discounted = (getPrice() == promoPrice); require(!paused, "Contract is paused"); require(amount > 0, "Amount is zero"); require(amount <= maxMint, "Amount exceeds max mint"); require(supply + amount <= maxSupply, "Max supply reached"); if (admins[msg.sender] != true) { if (discounted) { require(promos[to] + amount <= maxDiscountedMintPerUser, "Max discounted NFT exceeded for this user"); } require(getPrice().mul(amount) == msg.value, "Ether value sent is not correct"); } for (uint i = 1; i <= amount; i++) { _safeMint(to, supply + i); if(discounted) { promos[to] = promos[to] + 1; } } } function gift(address to, uint amount) external onlyAdmin { uint supply = totalSupply(); require(!paused, "Contract is paused"); require(amount > 0, "Amount is zero"); require(amount <= maxMint, "Amount exceeds max mint"); require(supply + amount <= maxSupply, "Max supply reached"); for (uint i = 1; i <= amount; i++) { _safeMint(to, supply + i); } } function airdrop(address to, uint tokenId) external onlyAdmin { require(!paused, "Contract is paused"); require(to != address(0), "Can't airdrop to a zero address"); safeTransferFrom(msg.sender, to, tokenId); emit Airdropped(to, tokenId); } // *************************** // Game management // *************************** // Main function to draw the roadmap prizes and pay the winners function draw() external payable onlyAdmin { require(!paused, "Contract is paused"); releaseAll(); uint[] memory prizes = consumeRoadmapPrizes(totalSupply()); uint nonce = block.difficulty; for (uint i = 0; i < prizes.length; i++) { uint tokenId = randToken(i, nonce); require(tokenId != 0, "Incorrect tokenId"); address winner = ownerOf(tokenId); require(winner != address(0), "Can't pay a zero address"); pay(payable(winner), (prizes[i] * MILLIETHER)); nonce=nonce^uint(keccak256(abi.encodePacked(winner))); emit Winner(tokenId, winner, prizes[i]); } } // Alternative draw method to choose one random winner with a given prize function drawOne(uint milliEther) external payable onlyAdmin { require(!paused, "Contract is paused"); releaseAll(); uint seed = uint(keccak256(abi.encodePacked(block.coinbase))); uint nonce = uint(keccak256(abi.encodePacked(msg.sender))); uint tokenId = randToken(seed, nonce); require(tokenId != 0, "Incorrect tokenId"); address winner = ownerOf(tokenId); require(winner != address(0), "Can't pay a zero address"); pay(payable(winner), (milliEther * MILLIETHER)); emit Winner(tokenId, winner, milliEther); } // *************************** // Internals // *************************** // Initialize the roadmap function initRoadmap() internal onlyAdmin { roadmap[0] = RoadmapStep(1000,2,22000,1); roadmap[1] = RoadmapStep(2000,3,22000,1); roadmap[2] = RoadmapStep(3000,1,44000,1); roadmap[3] = RoadmapStep(4000,1,44000,1); roadmap[4] = RoadmapStep(5000,50,1100,2); roadmap[5] = RoadmapStep(7000,50,1100,2); roadmap[6] = RoadmapStep(7000,10,11000,1); roadmap[7] = RoadmapStep(10000,1,220000,1); roadmap[8] = RoadmapStep(10000,50,2200,1); } // Consume some prizes according to the roadmap // Rule : winnersCount per week and only one prizeValue same amount at a time. function consumeRoadmapPrizes(uint supply) internal onlyAdmin returns (uint[] memory) { uint index = 0; uint[] memory temp = new uint[](16); for (uint i = 0; i < 9; i++) { isPrizeGiven[roadmap[i].prizeValue] = false; } for (uint i = 0; i < roadmap.length; i++) { if (roadmap[i].supply > supply) { break; } if ((roadmap[i].supply <= supply) && (roadmap[i].winnersCount > 0) && !isPrizeGiven[roadmap[i].prizeValue]) { for (uint j = 0; j < Math.min(roadmap[i].winnersToDraw, roadmap[i].winnersCount); j++) { roadmap[i].winnersCount--; temp[index] = roadmap[i].prizeValue; index++; } isPrizeGiven[roadmap[i].prizeValue] = true; } } uint[] memory prizes = new uint[](index); for (uint i = 0; i < index; i++) { prizes[i] = temp[i]; } return prizes; } // Randomly picks a tokenId function randToken(uint seed, uint nonce) internal view onlyAdmin returns(uint) { uint supply = totalSupply(); if (supply > 0) { uint tokenId = randModulus(supply, seed, nonce); if (tokenId > 0) { return tokenId; } } return 0; } // Pays eth amount to an address function pay(address payable to, uint amount) internal onlyAdmin { require(to != address(0), "Can't pay a zero address"); require(address(this).balance >= amount, "No sufficient fund in contract to pay the address"); (bool sent, bytes memory data) = to.call{value: amount}(""); if (sent) { addToReleased(amount); } require(sent, string(abi.encodePacked("Failed to send Ether:", data))); } // Gets a random number function randModulus(uint max, uint seed, uint nonce) internal view returns(uint) { uint blockNumber = block.number-1; if (block.number>(seed % 256)) { blockNumber=block.number-(seed % 256); } uint rand = uint(keccak256(abi.encodePacked( seed^block.timestamp, block.timestamp, msg.data, nonce, msg.sender, blockhash(blockNumber) ) )) % max; return rand+1; } }
draw
function draw() external payable onlyAdmin { require(!paused, "Contract is paused"); releaseAll(); uint[] memory prizes = consumeRoadmapPrizes(totalSupply()); uint nonce = block.difficulty; for (uint i = 0; i < prizes.length; i++) { uint tokenId = randToken(i, nonce); require(tokenId != 0, "Incorrect tokenId"); address winner = ownerOf(tokenId); require(winner != address(0), "Can't pay a zero address"); pay(payable(winner), (prizes[i] * MILLIETHER)); nonce=nonce^uint(keccak256(abi.encodePacked(winner))); emit Winner(tokenId, winner, prizes[i]); } }
// *************************** // Game management // *************************** // Main function to draw the roadmap prizes and pay the winners
LineComment
v0.8.7+commit.e28d00a7
MIT
ipfs://414d9951eb094e9f3eecc45ff7dcf1c7de317858d1ad8616b1355e70b4b69e2c
{ "func_code_index": [ 10521, 11230 ] }
58,691
MegaMilionsGangstarApes
MegaMilionsGangstarApes.sol
0x3af32fd45224c502469af10e8fff285c18a978bc
Solidity
MegaMilionsGangstarApes
contract MegaMilionsGangstarApes is ERC721, ERC721Enumerable, ERC721URIStorage, ERC2981ContractWideRoyalties, Ownable, PaymentSplitter { using Counters for Counters.Counter; using Strings for uint; using Math for uint; using SafeMath for uint; enum PriceType{ PROMO, FULL } //{ 0, 1 } struct Promo { uint startTime; uint duration; } // Mappings mapping(address => bool) public whitelisted; mapping(address => uint) public promos; mapping(address => bool) public admins; // Default values uint internal constant MILLIETHER = 1e15; //0.001 ETHER = 1,000,000,000,000,000 WEI uint internal promoPrice = 0.1 ether; uint internal fullPrice = 0.3 ether; uint internal maxSupply = 10000; uint internal maxMint = 10; uint internal maxDiscountedMintPerUser = 2; // Vars string private baseURI; bool private paused = false; Promo private promo; // Wallet shares - 50% of revenues shared to team address private DP = 0xcd70Dc892F240D50b7D46CE120dc75c3243E72ab; address private RG = 0x39c34674EEC3AE5F1E9a6Ee899CB85f11a55D990; address private JH = 0xD484E2745d27FA62E6ab0396fd46e0A3E3A00eFc; address private LH = 0xB2CEe0977Bbb0446B358E0Cb3de69e10EdC5eDA3; address private EA = 0x3a4FF805cD9C063f06a0263EEa99F531FAa13B91; address private AG = 0x79f6E63B4D593F3794019A4FEFB52196C602E037; address private JP = 0xd7EE8aF7a902bb208878E50863220e2872b73992; address private MR = 0xaFBC38a36Cb173d75735f3f781e9133939e99888; address private AF = 0x7a2DD031a02Fd595C7BCb0A278A4518daB31AF8d; address private MA = 0xEe3642cb451F6f4ec5C6dd6699fFE69F2D07921E; uint[] private _shares = [ 675, 675, 11250, 6750, 9865, 6750, 7865, 270, 675, 5225 ]; address[] private _team = [ DP, RG, JH, LH, EA, AG, JP, MR, AF, MA ]; // Game struct RoadmapStep { uint64 supply; uint64 winnersCount; uint64 prizeValue; uint64 winnersToDraw; } uint private drawIndex = 0; RoadmapStep[9] private roadmap; mapping(uint => bool) internal isPrizeGiven; // Modifiers modifier onlyAdmin() { require(address(this) == _msgSender() || owner() == _msgSender() || admins[msg.sender], "Not admin"); _; } // Emitters event BaseURIChanged(string tokenBaseURI); event TicketPriceChanged(PriceType priceType, uint price); event MaxMintAmountChanged(uint amount); event MaxDiscountedMintPerUser(uint mintPerUser); event Paused(bool paused); event PromoChanged(uint startTime, uint duration); event Airdropped(address to, uint tokenId); event Winner(uint token, address winner, uint value); event Log(string error); constructor() ERC721("Mega Millions Gangstar Apes", "MMGA") PaymentSplitter(_team, _shares) { //set default admins admins[DP] = true; admins[RG] = true; initRoadmap(); //if ERC2981 supported _setRoyalties(address(this), 1000); //10% } // *************************** // Overrides // *************************** function _beforeTokenTransfer(address from, address to, uint tokenId) internal override(ERC721, ERC721Enumerable) { super._beforeTokenTransfer(from, to, tokenId); } function supportsInterface(bytes4 interfaceId) public view override(ERC721, ERC721Enumerable, ERC2981Base) returns (bool) { return super.supportsInterface(interfaceId); } function _burn(uint _tokenId) internal override(ERC721, ERC721URIStorage) { super._burn(_tokenId); } function burn(uint _tokenId) external onlyAdmin { _burn(_tokenId); maxSupply = maxSupply - 1; } // *************************** // Admins management by owner // *************************** function enableAdmin(address addr) external onlyOwner { admins[addr] = true; } function disableAdmin(address addr) external onlyOwner { require(addr != owner(), "Can't disable owner"); admins[addr] = false; } // *************************** // Release & withdraw // *************************** function releaseAll() public onlyAdmin { for (uint i = 0; i < _team.length; i++) { address member = _team[i]; try this.release(payable(member)) {} catch Error(string memory revertReason) { emit Log(revertReason); } catch (bytes memory returnData) { emit Log(string(returnData)); } } } function withdraw() external onlyAdmin { releaseAll(); pay(payable(owner()), address(this).balance); } // *************************** // Contract management // *************************** function pause(bool newState) external onlyAdmin { paused = newState; emit Paused(newState); } function addWhitelistedUsers(address[] calldata users) external onlyAdmin { for (uint i = 0; i < users.length; i++) { require(users[i] != address(0), "Can't add a zero address"); if (whitelisted[users[i]] == false) { whitelisted[users[i]] = true; } } } function removeWhitelistedUsers(address[] calldata users) external onlyAdmin { for (uint i = 0; i < users.length; i++) { require(users[i] != address(0), "Can't remove a zero address"); if (whitelisted[users[i]] == true) { whitelisted[users[i]] = false; } } } // Duration in seconds function startPromo(uint duration) external onlyAdmin { uint startTime = block.timestamp; promo = Promo(startTime, duration); emit PromoChanged(startTime, duration); } // *************************** // URI management (Reveal) // *************************** function _baseURI() internal view virtual override returns (string memory) { return baseURI; } function setBaseURI(string memory newBaseURI) external onlyAdmin { baseURI = newBaseURI; emit BaseURIChanged(newBaseURI); } function setTokenURI(uint _tokenId, string memory _tokenURI) external onlyAdmin { require(_exists(_tokenId), "URI set of nonexistent token"); _setTokenURI(_tokenId, _tokenURI); } function tokenURI(uint _tokenId) public view override(ERC721, ERC721URIStorage) returns (string memory) { return super.tokenURI(_tokenId); } // *************************** // Promo & price management // *************************** function setPrice(PriceType priceType, uint price) external onlyAdmin { require(price > 0, "Zero price"); if (priceType == PriceType.PROMO) { promoPrice = price; } else if (priceType == PriceType.FULL) { fullPrice = price; } emit TicketPriceChanged(priceType, price); } function setMaxMintAmount(uint amount) external onlyAdmin { maxMint = amount; emit MaxMintAmountChanged(amount); } function setMaxDiscountedMintPerUser(uint mintPerUser) external onlyAdmin { maxDiscountedMintPerUser = mintPerUser; emit MaxDiscountedMintPerUser(mintPerUser); } function isPromo() public view returns (bool) { return (promo.startTime > 0 && block.timestamp >= promo.startTime && block.timestamp <= (promo.startTime + promo.duration)); } // Dynamically gets the token price according to promo, whitelist and msg.sender function getPrice() public view returns (uint) { uint price = fullPrice; if (admins[msg.sender] == true) { price = 0; } else if ((isPromo() || whitelisted[msg.sender] == true) && promos[msg.sender] < maxDiscountedMintPerUser) { price = promoPrice; } return price; } // *************************** // Mint, Gift & Airdrop // *************************** function mint(address to, uint amount) external payable { uint supply = totalSupply(); bool discounted = (getPrice() == promoPrice); require(!paused, "Contract is paused"); require(amount > 0, "Amount is zero"); require(amount <= maxMint, "Amount exceeds max mint"); require(supply + amount <= maxSupply, "Max supply reached"); if (admins[msg.sender] != true) { if (discounted) { require(promos[to] + amount <= maxDiscountedMintPerUser, "Max discounted NFT exceeded for this user"); } require(getPrice().mul(amount) == msg.value, "Ether value sent is not correct"); } for (uint i = 1; i <= amount; i++) { _safeMint(to, supply + i); if(discounted) { promos[to] = promos[to] + 1; } } } function gift(address to, uint amount) external onlyAdmin { uint supply = totalSupply(); require(!paused, "Contract is paused"); require(amount > 0, "Amount is zero"); require(amount <= maxMint, "Amount exceeds max mint"); require(supply + amount <= maxSupply, "Max supply reached"); for (uint i = 1; i <= amount; i++) { _safeMint(to, supply + i); } } function airdrop(address to, uint tokenId) external onlyAdmin { require(!paused, "Contract is paused"); require(to != address(0), "Can't airdrop to a zero address"); safeTransferFrom(msg.sender, to, tokenId); emit Airdropped(to, tokenId); } // *************************** // Game management // *************************** // Main function to draw the roadmap prizes and pay the winners function draw() external payable onlyAdmin { require(!paused, "Contract is paused"); releaseAll(); uint[] memory prizes = consumeRoadmapPrizes(totalSupply()); uint nonce = block.difficulty; for (uint i = 0; i < prizes.length; i++) { uint tokenId = randToken(i, nonce); require(tokenId != 0, "Incorrect tokenId"); address winner = ownerOf(tokenId); require(winner != address(0), "Can't pay a zero address"); pay(payable(winner), (prizes[i] * MILLIETHER)); nonce=nonce^uint(keccak256(abi.encodePacked(winner))); emit Winner(tokenId, winner, prizes[i]); } } // Alternative draw method to choose one random winner with a given prize function drawOne(uint milliEther) external payable onlyAdmin { require(!paused, "Contract is paused"); releaseAll(); uint seed = uint(keccak256(abi.encodePacked(block.coinbase))); uint nonce = uint(keccak256(abi.encodePacked(msg.sender))); uint tokenId = randToken(seed, nonce); require(tokenId != 0, "Incorrect tokenId"); address winner = ownerOf(tokenId); require(winner != address(0), "Can't pay a zero address"); pay(payable(winner), (milliEther * MILLIETHER)); emit Winner(tokenId, winner, milliEther); } // *************************** // Internals // *************************** // Initialize the roadmap function initRoadmap() internal onlyAdmin { roadmap[0] = RoadmapStep(1000,2,22000,1); roadmap[1] = RoadmapStep(2000,3,22000,1); roadmap[2] = RoadmapStep(3000,1,44000,1); roadmap[3] = RoadmapStep(4000,1,44000,1); roadmap[4] = RoadmapStep(5000,50,1100,2); roadmap[5] = RoadmapStep(7000,50,1100,2); roadmap[6] = RoadmapStep(7000,10,11000,1); roadmap[7] = RoadmapStep(10000,1,220000,1); roadmap[8] = RoadmapStep(10000,50,2200,1); } // Consume some prizes according to the roadmap // Rule : winnersCount per week and only one prizeValue same amount at a time. function consumeRoadmapPrizes(uint supply) internal onlyAdmin returns (uint[] memory) { uint index = 0; uint[] memory temp = new uint[](16); for (uint i = 0; i < 9; i++) { isPrizeGiven[roadmap[i].prizeValue] = false; } for (uint i = 0; i < roadmap.length; i++) { if (roadmap[i].supply > supply) { break; } if ((roadmap[i].supply <= supply) && (roadmap[i].winnersCount > 0) && !isPrizeGiven[roadmap[i].prizeValue]) { for (uint j = 0; j < Math.min(roadmap[i].winnersToDraw, roadmap[i].winnersCount); j++) { roadmap[i].winnersCount--; temp[index] = roadmap[i].prizeValue; index++; } isPrizeGiven[roadmap[i].prizeValue] = true; } } uint[] memory prizes = new uint[](index); for (uint i = 0; i < index; i++) { prizes[i] = temp[i]; } return prizes; } // Randomly picks a tokenId function randToken(uint seed, uint nonce) internal view onlyAdmin returns(uint) { uint supply = totalSupply(); if (supply > 0) { uint tokenId = randModulus(supply, seed, nonce); if (tokenId > 0) { return tokenId; } } return 0; } // Pays eth amount to an address function pay(address payable to, uint amount) internal onlyAdmin { require(to != address(0), "Can't pay a zero address"); require(address(this).balance >= amount, "No sufficient fund in contract to pay the address"); (bool sent, bytes memory data) = to.call{value: amount}(""); if (sent) { addToReleased(amount); } require(sent, string(abi.encodePacked("Failed to send Ether:", data))); } // Gets a random number function randModulus(uint max, uint seed, uint nonce) internal view returns(uint) { uint blockNumber = block.number-1; if (block.number>(seed % 256)) { blockNumber=block.number-(seed % 256); } uint rand = uint(keccak256(abi.encodePacked( seed^block.timestamp, block.timestamp, msg.data, nonce, msg.sender, blockhash(blockNumber) ) )) % max; return rand+1; } }
drawOne
function drawOne(uint milliEther) external payable onlyAdmin { require(!paused, "Contract is paused"); releaseAll(); uint seed = uint(keccak256(abi.encodePacked(block.coinbase))); uint nonce = uint(keccak256(abi.encodePacked(msg.sender))); uint tokenId = randToken(seed, nonce); require(tokenId != 0, "Incorrect tokenId"); address winner = ownerOf(tokenId); require(winner != address(0), "Can't pay a zero address"); pay(payable(winner), (milliEther * MILLIETHER)); emit Winner(tokenId, winner, milliEther); }
// Alternative draw method to choose one random winner with a given prize
LineComment
v0.8.7+commit.e28d00a7
MIT
ipfs://414d9951eb094e9f3eecc45ff7dcf1c7de317858d1ad8616b1355e70b4b69e2c
{ "func_code_index": [ 11316, 11925 ] }
58,692
MegaMilionsGangstarApes
MegaMilionsGangstarApes.sol
0x3af32fd45224c502469af10e8fff285c18a978bc
Solidity
MegaMilionsGangstarApes
contract MegaMilionsGangstarApes is ERC721, ERC721Enumerable, ERC721URIStorage, ERC2981ContractWideRoyalties, Ownable, PaymentSplitter { using Counters for Counters.Counter; using Strings for uint; using Math for uint; using SafeMath for uint; enum PriceType{ PROMO, FULL } //{ 0, 1 } struct Promo { uint startTime; uint duration; } // Mappings mapping(address => bool) public whitelisted; mapping(address => uint) public promos; mapping(address => bool) public admins; // Default values uint internal constant MILLIETHER = 1e15; //0.001 ETHER = 1,000,000,000,000,000 WEI uint internal promoPrice = 0.1 ether; uint internal fullPrice = 0.3 ether; uint internal maxSupply = 10000; uint internal maxMint = 10; uint internal maxDiscountedMintPerUser = 2; // Vars string private baseURI; bool private paused = false; Promo private promo; // Wallet shares - 50% of revenues shared to team address private DP = 0xcd70Dc892F240D50b7D46CE120dc75c3243E72ab; address private RG = 0x39c34674EEC3AE5F1E9a6Ee899CB85f11a55D990; address private JH = 0xD484E2745d27FA62E6ab0396fd46e0A3E3A00eFc; address private LH = 0xB2CEe0977Bbb0446B358E0Cb3de69e10EdC5eDA3; address private EA = 0x3a4FF805cD9C063f06a0263EEa99F531FAa13B91; address private AG = 0x79f6E63B4D593F3794019A4FEFB52196C602E037; address private JP = 0xd7EE8aF7a902bb208878E50863220e2872b73992; address private MR = 0xaFBC38a36Cb173d75735f3f781e9133939e99888; address private AF = 0x7a2DD031a02Fd595C7BCb0A278A4518daB31AF8d; address private MA = 0xEe3642cb451F6f4ec5C6dd6699fFE69F2D07921E; uint[] private _shares = [ 675, 675, 11250, 6750, 9865, 6750, 7865, 270, 675, 5225 ]; address[] private _team = [ DP, RG, JH, LH, EA, AG, JP, MR, AF, MA ]; // Game struct RoadmapStep { uint64 supply; uint64 winnersCount; uint64 prizeValue; uint64 winnersToDraw; } uint private drawIndex = 0; RoadmapStep[9] private roadmap; mapping(uint => bool) internal isPrizeGiven; // Modifiers modifier onlyAdmin() { require(address(this) == _msgSender() || owner() == _msgSender() || admins[msg.sender], "Not admin"); _; } // Emitters event BaseURIChanged(string tokenBaseURI); event TicketPriceChanged(PriceType priceType, uint price); event MaxMintAmountChanged(uint amount); event MaxDiscountedMintPerUser(uint mintPerUser); event Paused(bool paused); event PromoChanged(uint startTime, uint duration); event Airdropped(address to, uint tokenId); event Winner(uint token, address winner, uint value); event Log(string error); constructor() ERC721("Mega Millions Gangstar Apes", "MMGA") PaymentSplitter(_team, _shares) { //set default admins admins[DP] = true; admins[RG] = true; initRoadmap(); //if ERC2981 supported _setRoyalties(address(this), 1000); //10% } // *************************** // Overrides // *************************** function _beforeTokenTransfer(address from, address to, uint tokenId) internal override(ERC721, ERC721Enumerable) { super._beforeTokenTransfer(from, to, tokenId); } function supportsInterface(bytes4 interfaceId) public view override(ERC721, ERC721Enumerable, ERC2981Base) returns (bool) { return super.supportsInterface(interfaceId); } function _burn(uint _tokenId) internal override(ERC721, ERC721URIStorage) { super._burn(_tokenId); } function burn(uint _tokenId) external onlyAdmin { _burn(_tokenId); maxSupply = maxSupply - 1; } // *************************** // Admins management by owner // *************************** function enableAdmin(address addr) external onlyOwner { admins[addr] = true; } function disableAdmin(address addr) external onlyOwner { require(addr != owner(), "Can't disable owner"); admins[addr] = false; } // *************************** // Release & withdraw // *************************** function releaseAll() public onlyAdmin { for (uint i = 0; i < _team.length; i++) { address member = _team[i]; try this.release(payable(member)) {} catch Error(string memory revertReason) { emit Log(revertReason); } catch (bytes memory returnData) { emit Log(string(returnData)); } } } function withdraw() external onlyAdmin { releaseAll(); pay(payable(owner()), address(this).balance); } // *************************** // Contract management // *************************** function pause(bool newState) external onlyAdmin { paused = newState; emit Paused(newState); } function addWhitelistedUsers(address[] calldata users) external onlyAdmin { for (uint i = 0; i < users.length; i++) { require(users[i] != address(0), "Can't add a zero address"); if (whitelisted[users[i]] == false) { whitelisted[users[i]] = true; } } } function removeWhitelistedUsers(address[] calldata users) external onlyAdmin { for (uint i = 0; i < users.length; i++) { require(users[i] != address(0), "Can't remove a zero address"); if (whitelisted[users[i]] == true) { whitelisted[users[i]] = false; } } } // Duration in seconds function startPromo(uint duration) external onlyAdmin { uint startTime = block.timestamp; promo = Promo(startTime, duration); emit PromoChanged(startTime, duration); } // *************************** // URI management (Reveal) // *************************** function _baseURI() internal view virtual override returns (string memory) { return baseURI; } function setBaseURI(string memory newBaseURI) external onlyAdmin { baseURI = newBaseURI; emit BaseURIChanged(newBaseURI); } function setTokenURI(uint _tokenId, string memory _tokenURI) external onlyAdmin { require(_exists(_tokenId), "URI set of nonexistent token"); _setTokenURI(_tokenId, _tokenURI); } function tokenURI(uint _tokenId) public view override(ERC721, ERC721URIStorage) returns (string memory) { return super.tokenURI(_tokenId); } // *************************** // Promo & price management // *************************** function setPrice(PriceType priceType, uint price) external onlyAdmin { require(price > 0, "Zero price"); if (priceType == PriceType.PROMO) { promoPrice = price; } else if (priceType == PriceType.FULL) { fullPrice = price; } emit TicketPriceChanged(priceType, price); } function setMaxMintAmount(uint amount) external onlyAdmin { maxMint = amount; emit MaxMintAmountChanged(amount); } function setMaxDiscountedMintPerUser(uint mintPerUser) external onlyAdmin { maxDiscountedMintPerUser = mintPerUser; emit MaxDiscountedMintPerUser(mintPerUser); } function isPromo() public view returns (bool) { return (promo.startTime > 0 && block.timestamp >= promo.startTime && block.timestamp <= (promo.startTime + promo.duration)); } // Dynamically gets the token price according to promo, whitelist and msg.sender function getPrice() public view returns (uint) { uint price = fullPrice; if (admins[msg.sender] == true) { price = 0; } else if ((isPromo() || whitelisted[msg.sender] == true) && promos[msg.sender] < maxDiscountedMintPerUser) { price = promoPrice; } return price; } // *************************** // Mint, Gift & Airdrop // *************************** function mint(address to, uint amount) external payable { uint supply = totalSupply(); bool discounted = (getPrice() == promoPrice); require(!paused, "Contract is paused"); require(amount > 0, "Amount is zero"); require(amount <= maxMint, "Amount exceeds max mint"); require(supply + amount <= maxSupply, "Max supply reached"); if (admins[msg.sender] != true) { if (discounted) { require(promos[to] + amount <= maxDiscountedMintPerUser, "Max discounted NFT exceeded for this user"); } require(getPrice().mul(amount) == msg.value, "Ether value sent is not correct"); } for (uint i = 1; i <= amount; i++) { _safeMint(to, supply + i); if(discounted) { promos[to] = promos[to] + 1; } } } function gift(address to, uint amount) external onlyAdmin { uint supply = totalSupply(); require(!paused, "Contract is paused"); require(amount > 0, "Amount is zero"); require(amount <= maxMint, "Amount exceeds max mint"); require(supply + amount <= maxSupply, "Max supply reached"); for (uint i = 1; i <= amount; i++) { _safeMint(to, supply + i); } } function airdrop(address to, uint tokenId) external onlyAdmin { require(!paused, "Contract is paused"); require(to != address(0), "Can't airdrop to a zero address"); safeTransferFrom(msg.sender, to, tokenId); emit Airdropped(to, tokenId); } // *************************** // Game management // *************************** // Main function to draw the roadmap prizes and pay the winners function draw() external payable onlyAdmin { require(!paused, "Contract is paused"); releaseAll(); uint[] memory prizes = consumeRoadmapPrizes(totalSupply()); uint nonce = block.difficulty; for (uint i = 0; i < prizes.length; i++) { uint tokenId = randToken(i, nonce); require(tokenId != 0, "Incorrect tokenId"); address winner = ownerOf(tokenId); require(winner != address(0), "Can't pay a zero address"); pay(payable(winner), (prizes[i] * MILLIETHER)); nonce=nonce^uint(keccak256(abi.encodePacked(winner))); emit Winner(tokenId, winner, prizes[i]); } } // Alternative draw method to choose one random winner with a given prize function drawOne(uint milliEther) external payable onlyAdmin { require(!paused, "Contract is paused"); releaseAll(); uint seed = uint(keccak256(abi.encodePacked(block.coinbase))); uint nonce = uint(keccak256(abi.encodePacked(msg.sender))); uint tokenId = randToken(seed, nonce); require(tokenId != 0, "Incorrect tokenId"); address winner = ownerOf(tokenId); require(winner != address(0), "Can't pay a zero address"); pay(payable(winner), (milliEther * MILLIETHER)); emit Winner(tokenId, winner, milliEther); } // *************************** // Internals // *************************** // Initialize the roadmap function initRoadmap() internal onlyAdmin { roadmap[0] = RoadmapStep(1000,2,22000,1); roadmap[1] = RoadmapStep(2000,3,22000,1); roadmap[2] = RoadmapStep(3000,1,44000,1); roadmap[3] = RoadmapStep(4000,1,44000,1); roadmap[4] = RoadmapStep(5000,50,1100,2); roadmap[5] = RoadmapStep(7000,50,1100,2); roadmap[6] = RoadmapStep(7000,10,11000,1); roadmap[7] = RoadmapStep(10000,1,220000,1); roadmap[8] = RoadmapStep(10000,50,2200,1); } // Consume some prizes according to the roadmap // Rule : winnersCount per week and only one prizeValue same amount at a time. function consumeRoadmapPrizes(uint supply) internal onlyAdmin returns (uint[] memory) { uint index = 0; uint[] memory temp = new uint[](16); for (uint i = 0; i < 9; i++) { isPrizeGiven[roadmap[i].prizeValue] = false; } for (uint i = 0; i < roadmap.length; i++) { if (roadmap[i].supply > supply) { break; } if ((roadmap[i].supply <= supply) && (roadmap[i].winnersCount > 0) && !isPrizeGiven[roadmap[i].prizeValue]) { for (uint j = 0; j < Math.min(roadmap[i].winnersToDraw, roadmap[i].winnersCount); j++) { roadmap[i].winnersCount--; temp[index] = roadmap[i].prizeValue; index++; } isPrizeGiven[roadmap[i].prizeValue] = true; } } uint[] memory prizes = new uint[](index); for (uint i = 0; i < index; i++) { prizes[i] = temp[i]; } return prizes; } // Randomly picks a tokenId function randToken(uint seed, uint nonce) internal view onlyAdmin returns(uint) { uint supply = totalSupply(); if (supply > 0) { uint tokenId = randModulus(supply, seed, nonce); if (tokenId > 0) { return tokenId; } } return 0; } // Pays eth amount to an address function pay(address payable to, uint amount) internal onlyAdmin { require(to != address(0), "Can't pay a zero address"); require(address(this).balance >= amount, "No sufficient fund in contract to pay the address"); (bool sent, bytes memory data) = to.call{value: amount}(""); if (sent) { addToReleased(amount); } require(sent, string(abi.encodePacked("Failed to send Ether:", data))); } // Gets a random number function randModulus(uint max, uint seed, uint nonce) internal view returns(uint) { uint blockNumber = block.number-1; if (block.number>(seed % 256)) { blockNumber=block.number-(seed % 256); } uint rand = uint(keccak256(abi.encodePacked( seed^block.timestamp, block.timestamp, msg.data, nonce, msg.sender, blockhash(blockNumber) ) )) % max; return rand+1; } }
initRoadmap
function initRoadmap() internal onlyAdmin { roadmap[0] = RoadmapStep(1000,2,22000,1); roadmap[1] = RoadmapStep(2000,3,22000,1); roadmap[2] = RoadmapStep(3000,1,44000,1); roadmap[3] = RoadmapStep(4000,1,44000,1); roadmap[4] = RoadmapStep(5000,50,1100,2); roadmap[5] = RoadmapStep(7000,50,1100,2); roadmap[6] = RoadmapStep(7000,10,11000,1); roadmap[7] = RoadmapStep(10000,1,220000,1); roadmap[8] = RoadmapStep(10000,50,2200,1); }
// *************************** // Internals // *************************** // Initialize the roadmap
LineComment
v0.8.7+commit.e28d00a7
MIT
ipfs://414d9951eb094e9f3eecc45ff7dcf1c7de317858d1ad8616b1355e70b4b69e2c
{ "func_code_index": [ 12060, 12578 ] }
58,693
MegaMilionsGangstarApes
MegaMilionsGangstarApes.sol
0x3af32fd45224c502469af10e8fff285c18a978bc
Solidity
MegaMilionsGangstarApes
contract MegaMilionsGangstarApes is ERC721, ERC721Enumerable, ERC721URIStorage, ERC2981ContractWideRoyalties, Ownable, PaymentSplitter { using Counters for Counters.Counter; using Strings for uint; using Math for uint; using SafeMath for uint; enum PriceType{ PROMO, FULL } //{ 0, 1 } struct Promo { uint startTime; uint duration; } // Mappings mapping(address => bool) public whitelisted; mapping(address => uint) public promos; mapping(address => bool) public admins; // Default values uint internal constant MILLIETHER = 1e15; //0.001 ETHER = 1,000,000,000,000,000 WEI uint internal promoPrice = 0.1 ether; uint internal fullPrice = 0.3 ether; uint internal maxSupply = 10000; uint internal maxMint = 10; uint internal maxDiscountedMintPerUser = 2; // Vars string private baseURI; bool private paused = false; Promo private promo; // Wallet shares - 50% of revenues shared to team address private DP = 0xcd70Dc892F240D50b7D46CE120dc75c3243E72ab; address private RG = 0x39c34674EEC3AE5F1E9a6Ee899CB85f11a55D990; address private JH = 0xD484E2745d27FA62E6ab0396fd46e0A3E3A00eFc; address private LH = 0xB2CEe0977Bbb0446B358E0Cb3de69e10EdC5eDA3; address private EA = 0x3a4FF805cD9C063f06a0263EEa99F531FAa13B91; address private AG = 0x79f6E63B4D593F3794019A4FEFB52196C602E037; address private JP = 0xd7EE8aF7a902bb208878E50863220e2872b73992; address private MR = 0xaFBC38a36Cb173d75735f3f781e9133939e99888; address private AF = 0x7a2DD031a02Fd595C7BCb0A278A4518daB31AF8d; address private MA = 0xEe3642cb451F6f4ec5C6dd6699fFE69F2D07921E; uint[] private _shares = [ 675, 675, 11250, 6750, 9865, 6750, 7865, 270, 675, 5225 ]; address[] private _team = [ DP, RG, JH, LH, EA, AG, JP, MR, AF, MA ]; // Game struct RoadmapStep { uint64 supply; uint64 winnersCount; uint64 prizeValue; uint64 winnersToDraw; } uint private drawIndex = 0; RoadmapStep[9] private roadmap; mapping(uint => bool) internal isPrizeGiven; // Modifiers modifier onlyAdmin() { require(address(this) == _msgSender() || owner() == _msgSender() || admins[msg.sender], "Not admin"); _; } // Emitters event BaseURIChanged(string tokenBaseURI); event TicketPriceChanged(PriceType priceType, uint price); event MaxMintAmountChanged(uint amount); event MaxDiscountedMintPerUser(uint mintPerUser); event Paused(bool paused); event PromoChanged(uint startTime, uint duration); event Airdropped(address to, uint tokenId); event Winner(uint token, address winner, uint value); event Log(string error); constructor() ERC721("Mega Millions Gangstar Apes", "MMGA") PaymentSplitter(_team, _shares) { //set default admins admins[DP] = true; admins[RG] = true; initRoadmap(); //if ERC2981 supported _setRoyalties(address(this), 1000); //10% } // *************************** // Overrides // *************************** function _beforeTokenTransfer(address from, address to, uint tokenId) internal override(ERC721, ERC721Enumerable) { super._beforeTokenTransfer(from, to, tokenId); } function supportsInterface(bytes4 interfaceId) public view override(ERC721, ERC721Enumerable, ERC2981Base) returns (bool) { return super.supportsInterface(interfaceId); } function _burn(uint _tokenId) internal override(ERC721, ERC721URIStorage) { super._burn(_tokenId); } function burn(uint _tokenId) external onlyAdmin { _burn(_tokenId); maxSupply = maxSupply - 1; } // *************************** // Admins management by owner // *************************** function enableAdmin(address addr) external onlyOwner { admins[addr] = true; } function disableAdmin(address addr) external onlyOwner { require(addr != owner(), "Can't disable owner"); admins[addr] = false; } // *************************** // Release & withdraw // *************************** function releaseAll() public onlyAdmin { for (uint i = 0; i < _team.length; i++) { address member = _team[i]; try this.release(payable(member)) {} catch Error(string memory revertReason) { emit Log(revertReason); } catch (bytes memory returnData) { emit Log(string(returnData)); } } } function withdraw() external onlyAdmin { releaseAll(); pay(payable(owner()), address(this).balance); } // *************************** // Contract management // *************************** function pause(bool newState) external onlyAdmin { paused = newState; emit Paused(newState); } function addWhitelistedUsers(address[] calldata users) external onlyAdmin { for (uint i = 0; i < users.length; i++) { require(users[i] != address(0), "Can't add a zero address"); if (whitelisted[users[i]] == false) { whitelisted[users[i]] = true; } } } function removeWhitelistedUsers(address[] calldata users) external onlyAdmin { for (uint i = 0; i < users.length; i++) { require(users[i] != address(0), "Can't remove a zero address"); if (whitelisted[users[i]] == true) { whitelisted[users[i]] = false; } } } // Duration in seconds function startPromo(uint duration) external onlyAdmin { uint startTime = block.timestamp; promo = Promo(startTime, duration); emit PromoChanged(startTime, duration); } // *************************** // URI management (Reveal) // *************************** function _baseURI() internal view virtual override returns (string memory) { return baseURI; } function setBaseURI(string memory newBaseURI) external onlyAdmin { baseURI = newBaseURI; emit BaseURIChanged(newBaseURI); } function setTokenURI(uint _tokenId, string memory _tokenURI) external onlyAdmin { require(_exists(_tokenId), "URI set of nonexistent token"); _setTokenURI(_tokenId, _tokenURI); } function tokenURI(uint _tokenId) public view override(ERC721, ERC721URIStorage) returns (string memory) { return super.tokenURI(_tokenId); } // *************************** // Promo & price management // *************************** function setPrice(PriceType priceType, uint price) external onlyAdmin { require(price > 0, "Zero price"); if (priceType == PriceType.PROMO) { promoPrice = price; } else if (priceType == PriceType.FULL) { fullPrice = price; } emit TicketPriceChanged(priceType, price); } function setMaxMintAmount(uint amount) external onlyAdmin { maxMint = amount; emit MaxMintAmountChanged(amount); } function setMaxDiscountedMintPerUser(uint mintPerUser) external onlyAdmin { maxDiscountedMintPerUser = mintPerUser; emit MaxDiscountedMintPerUser(mintPerUser); } function isPromo() public view returns (bool) { return (promo.startTime > 0 && block.timestamp >= promo.startTime && block.timestamp <= (promo.startTime + promo.duration)); } // Dynamically gets the token price according to promo, whitelist and msg.sender function getPrice() public view returns (uint) { uint price = fullPrice; if (admins[msg.sender] == true) { price = 0; } else if ((isPromo() || whitelisted[msg.sender] == true) && promos[msg.sender] < maxDiscountedMintPerUser) { price = promoPrice; } return price; } // *************************** // Mint, Gift & Airdrop // *************************** function mint(address to, uint amount) external payable { uint supply = totalSupply(); bool discounted = (getPrice() == promoPrice); require(!paused, "Contract is paused"); require(amount > 0, "Amount is zero"); require(amount <= maxMint, "Amount exceeds max mint"); require(supply + amount <= maxSupply, "Max supply reached"); if (admins[msg.sender] != true) { if (discounted) { require(promos[to] + amount <= maxDiscountedMintPerUser, "Max discounted NFT exceeded for this user"); } require(getPrice().mul(amount) == msg.value, "Ether value sent is not correct"); } for (uint i = 1; i <= amount; i++) { _safeMint(to, supply + i); if(discounted) { promos[to] = promos[to] + 1; } } } function gift(address to, uint amount) external onlyAdmin { uint supply = totalSupply(); require(!paused, "Contract is paused"); require(amount > 0, "Amount is zero"); require(amount <= maxMint, "Amount exceeds max mint"); require(supply + amount <= maxSupply, "Max supply reached"); for (uint i = 1; i <= amount; i++) { _safeMint(to, supply + i); } } function airdrop(address to, uint tokenId) external onlyAdmin { require(!paused, "Contract is paused"); require(to != address(0), "Can't airdrop to a zero address"); safeTransferFrom(msg.sender, to, tokenId); emit Airdropped(to, tokenId); } // *************************** // Game management // *************************** // Main function to draw the roadmap prizes and pay the winners function draw() external payable onlyAdmin { require(!paused, "Contract is paused"); releaseAll(); uint[] memory prizes = consumeRoadmapPrizes(totalSupply()); uint nonce = block.difficulty; for (uint i = 0; i < prizes.length; i++) { uint tokenId = randToken(i, nonce); require(tokenId != 0, "Incorrect tokenId"); address winner = ownerOf(tokenId); require(winner != address(0), "Can't pay a zero address"); pay(payable(winner), (prizes[i] * MILLIETHER)); nonce=nonce^uint(keccak256(abi.encodePacked(winner))); emit Winner(tokenId, winner, prizes[i]); } } // Alternative draw method to choose one random winner with a given prize function drawOne(uint milliEther) external payable onlyAdmin { require(!paused, "Contract is paused"); releaseAll(); uint seed = uint(keccak256(abi.encodePacked(block.coinbase))); uint nonce = uint(keccak256(abi.encodePacked(msg.sender))); uint tokenId = randToken(seed, nonce); require(tokenId != 0, "Incorrect tokenId"); address winner = ownerOf(tokenId); require(winner != address(0), "Can't pay a zero address"); pay(payable(winner), (milliEther * MILLIETHER)); emit Winner(tokenId, winner, milliEther); } // *************************** // Internals // *************************** // Initialize the roadmap function initRoadmap() internal onlyAdmin { roadmap[0] = RoadmapStep(1000,2,22000,1); roadmap[1] = RoadmapStep(2000,3,22000,1); roadmap[2] = RoadmapStep(3000,1,44000,1); roadmap[3] = RoadmapStep(4000,1,44000,1); roadmap[4] = RoadmapStep(5000,50,1100,2); roadmap[5] = RoadmapStep(7000,50,1100,2); roadmap[6] = RoadmapStep(7000,10,11000,1); roadmap[7] = RoadmapStep(10000,1,220000,1); roadmap[8] = RoadmapStep(10000,50,2200,1); } // Consume some prizes according to the roadmap // Rule : winnersCount per week and only one prizeValue same amount at a time. function consumeRoadmapPrizes(uint supply) internal onlyAdmin returns (uint[] memory) { uint index = 0; uint[] memory temp = new uint[](16); for (uint i = 0; i < 9; i++) { isPrizeGiven[roadmap[i].prizeValue] = false; } for (uint i = 0; i < roadmap.length; i++) { if (roadmap[i].supply > supply) { break; } if ((roadmap[i].supply <= supply) && (roadmap[i].winnersCount > 0) && !isPrizeGiven[roadmap[i].prizeValue]) { for (uint j = 0; j < Math.min(roadmap[i].winnersToDraw, roadmap[i].winnersCount); j++) { roadmap[i].winnersCount--; temp[index] = roadmap[i].prizeValue; index++; } isPrizeGiven[roadmap[i].prizeValue] = true; } } uint[] memory prizes = new uint[](index); for (uint i = 0; i < index; i++) { prizes[i] = temp[i]; } return prizes; } // Randomly picks a tokenId function randToken(uint seed, uint nonce) internal view onlyAdmin returns(uint) { uint supply = totalSupply(); if (supply > 0) { uint tokenId = randModulus(supply, seed, nonce); if (tokenId > 0) { return tokenId; } } return 0; } // Pays eth amount to an address function pay(address payable to, uint amount) internal onlyAdmin { require(to != address(0), "Can't pay a zero address"); require(address(this).balance >= amount, "No sufficient fund in contract to pay the address"); (bool sent, bytes memory data) = to.call{value: amount}(""); if (sent) { addToReleased(amount); } require(sent, string(abi.encodePacked("Failed to send Ether:", data))); } // Gets a random number function randModulus(uint max, uint seed, uint nonce) internal view returns(uint) { uint blockNumber = block.number-1; if (block.number>(seed % 256)) { blockNumber=block.number-(seed % 256); } uint rand = uint(keccak256(abi.encodePacked( seed^block.timestamp, block.timestamp, msg.data, nonce, msg.sender, blockhash(blockNumber) ) )) % max; return rand+1; } }
consumeRoadmapPrizes
function consumeRoadmapPrizes(uint supply) internal onlyAdmin returns (uint[] memory) { uint index = 0; uint[] memory temp = new uint[](16); for (uint i = 0; i < 9; i++) { isPrizeGiven[roadmap[i].prizeValue] = false; } for (uint i = 0; i < roadmap.length; i++) { if (roadmap[i].supply > supply) { break; } if ((roadmap[i].supply <= supply) && (roadmap[i].winnersCount > 0) && !isPrizeGiven[roadmap[i].prizeValue]) { for (uint j = 0; j < Math.min(roadmap[i].winnersToDraw, roadmap[i].winnersCount); j++) { roadmap[i].winnersCount--; temp[index] = roadmap[i].prizeValue; index++; } isPrizeGiven[roadmap[i].prizeValue] = true; } } uint[] memory prizes = new uint[](index); for (uint i = 0; i < index; i++) { prizes[i] = temp[i]; } return prizes; }
// Consume some prizes according to the roadmap // Rule : winnersCount per week and only one prizeValue same amount at a time.
LineComment
v0.8.7+commit.e28d00a7
MIT
ipfs://414d9951eb094e9f3eecc45ff7dcf1c7de317858d1ad8616b1355e70b4b69e2c
{ "func_code_index": [ 12722, 13813 ] }
58,694
MegaMilionsGangstarApes
MegaMilionsGangstarApes.sol
0x3af32fd45224c502469af10e8fff285c18a978bc
Solidity
MegaMilionsGangstarApes
contract MegaMilionsGangstarApes is ERC721, ERC721Enumerable, ERC721URIStorage, ERC2981ContractWideRoyalties, Ownable, PaymentSplitter { using Counters for Counters.Counter; using Strings for uint; using Math for uint; using SafeMath for uint; enum PriceType{ PROMO, FULL } //{ 0, 1 } struct Promo { uint startTime; uint duration; } // Mappings mapping(address => bool) public whitelisted; mapping(address => uint) public promos; mapping(address => bool) public admins; // Default values uint internal constant MILLIETHER = 1e15; //0.001 ETHER = 1,000,000,000,000,000 WEI uint internal promoPrice = 0.1 ether; uint internal fullPrice = 0.3 ether; uint internal maxSupply = 10000; uint internal maxMint = 10; uint internal maxDiscountedMintPerUser = 2; // Vars string private baseURI; bool private paused = false; Promo private promo; // Wallet shares - 50% of revenues shared to team address private DP = 0xcd70Dc892F240D50b7D46CE120dc75c3243E72ab; address private RG = 0x39c34674EEC3AE5F1E9a6Ee899CB85f11a55D990; address private JH = 0xD484E2745d27FA62E6ab0396fd46e0A3E3A00eFc; address private LH = 0xB2CEe0977Bbb0446B358E0Cb3de69e10EdC5eDA3; address private EA = 0x3a4FF805cD9C063f06a0263EEa99F531FAa13B91; address private AG = 0x79f6E63B4D593F3794019A4FEFB52196C602E037; address private JP = 0xd7EE8aF7a902bb208878E50863220e2872b73992; address private MR = 0xaFBC38a36Cb173d75735f3f781e9133939e99888; address private AF = 0x7a2DD031a02Fd595C7BCb0A278A4518daB31AF8d; address private MA = 0xEe3642cb451F6f4ec5C6dd6699fFE69F2D07921E; uint[] private _shares = [ 675, 675, 11250, 6750, 9865, 6750, 7865, 270, 675, 5225 ]; address[] private _team = [ DP, RG, JH, LH, EA, AG, JP, MR, AF, MA ]; // Game struct RoadmapStep { uint64 supply; uint64 winnersCount; uint64 prizeValue; uint64 winnersToDraw; } uint private drawIndex = 0; RoadmapStep[9] private roadmap; mapping(uint => bool) internal isPrizeGiven; // Modifiers modifier onlyAdmin() { require(address(this) == _msgSender() || owner() == _msgSender() || admins[msg.sender], "Not admin"); _; } // Emitters event BaseURIChanged(string tokenBaseURI); event TicketPriceChanged(PriceType priceType, uint price); event MaxMintAmountChanged(uint amount); event MaxDiscountedMintPerUser(uint mintPerUser); event Paused(bool paused); event PromoChanged(uint startTime, uint duration); event Airdropped(address to, uint tokenId); event Winner(uint token, address winner, uint value); event Log(string error); constructor() ERC721("Mega Millions Gangstar Apes", "MMGA") PaymentSplitter(_team, _shares) { //set default admins admins[DP] = true; admins[RG] = true; initRoadmap(); //if ERC2981 supported _setRoyalties(address(this), 1000); //10% } // *************************** // Overrides // *************************** function _beforeTokenTransfer(address from, address to, uint tokenId) internal override(ERC721, ERC721Enumerable) { super._beforeTokenTransfer(from, to, tokenId); } function supportsInterface(bytes4 interfaceId) public view override(ERC721, ERC721Enumerable, ERC2981Base) returns (bool) { return super.supportsInterface(interfaceId); } function _burn(uint _tokenId) internal override(ERC721, ERC721URIStorage) { super._burn(_tokenId); } function burn(uint _tokenId) external onlyAdmin { _burn(_tokenId); maxSupply = maxSupply - 1; } // *************************** // Admins management by owner // *************************** function enableAdmin(address addr) external onlyOwner { admins[addr] = true; } function disableAdmin(address addr) external onlyOwner { require(addr != owner(), "Can't disable owner"); admins[addr] = false; } // *************************** // Release & withdraw // *************************** function releaseAll() public onlyAdmin { for (uint i = 0; i < _team.length; i++) { address member = _team[i]; try this.release(payable(member)) {} catch Error(string memory revertReason) { emit Log(revertReason); } catch (bytes memory returnData) { emit Log(string(returnData)); } } } function withdraw() external onlyAdmin { releaseAll(); pay(payable(owner()), address(this).balance); } // *************************** // Contract management // *************************** function pause(bool newState) external onlyAdmin { paused = newState; emit Paused(newState); } function addWhitelistedUsers(address[] calldata users) external onlyAdmin { for (uint i = 0; i < users.length; i++) { require(users[i] != address(0), "Can't add a zero address"); if (whitelisted[users[i]] == false) { whitelisted[users[i]] = true; } } } function removeWhitelistedUsers(address[] calldata users) external onlyAdmin { for (uint i = 0; i < users.length; i++) { require(users[i] != address(0), "Can't remove a zero address"); if (whitelisted[users[i]] == true) { whitelisted[users[i]] = false; } } } // Duration in seconds function startPromo(uint duration) external onlyAdmin { uint startTime = block.timestamp; promo = Promo(startTime, duration); emit PromoChanged(startTime, duration); } // *************************** // URI management (Reveal) // *************************** function _baseURI() internal view virtual override returns (string memory) { return baseURI; } function setBaseURI(string memory newBaseURI) external onlyAdmin { baseURI = newBaseURI; emit BaseURIChanged(newBaseURI); } function setTokenURI(uint _tokenId, string memory _tokenURI) external onlyAdmin { require(_exists(_tokenId), "URI set of nonexistent token"); _setTokenURI(_tokenId, _tokenURI); } function tokenURI(uint _tokenId) public view override(ERC721, ERC721URIStorage) returns (string memory) { return super.tokenURI(_tokenId); } // *************************** // Promo & price management // *************************** function setPrice(PriceType priceType, uint price) external onlyAdmin { require(price > 0, "Zero price"); if (priceType == PriceType.PROMO) { promoPrice = price; } else if (priceType == PriceType.FULL) { fullPrice = price; } emit TicketPriceChanged(priceType, price); } function setMaxMintAmount(uint amount) external onlyAdmin { maxMint = amount; emit MaxMintAmountChanged(amount); } function setMaxDiscountedMintPerUser(uint mintPerUser) external onlyAdmin { maxDiscountedMintPerUser = mintPerUser; emit MaxDiscountedMintPerUser(mintPerUser); } function isPromo() public view returns (bool) { return (promo.startTime > 0 && block.timestamp >= promo.startTime && block.timestamp <= (promo.startTime + promo.duration)); } // Dynamically gets the token price according to promo, whitelist and msg.sender function getPrice() public view returns (uint) { uint price = fullPrice; if (admins[msg.sender] == true) { price = 0; } else if ((isPromo() || whitelisted[msg.sender] == true) && promos[msg.sender] < maxDiscountedMintPerUser) { price = promoPrice; } return price; } // *************************** // Mint, Gift & Airdrop // *************************** function mint(address to, uint amount) external payable { uint supply = totalSupply(); bool discounted = (getPrice() == promoPrice); require(!paused, "Contract is paused"); require(amount > 0, "Amount is zero"); require(amount <= maxMint, "Amount exceeds max mint"); require(supply + amount <= maxSupply, "Max supply reached"); if (admins[msg.sender] != true) { if (discounted) { require(promos[to] + amount <= maxDiscountedMintPerUser, "Max discounted NFT exceeded for this user"); } require(getPrice().mul(amount) == msg.value, "Ether value sent is not correct"); } for (uint i = 1; i <= amount; i++) { _safeMint(to, supply + i); if(discounted) { promos[to] = promos[to] + 1; } } } function gift(address to, uint amount) external onlyAdmin { uint supply = totalSupply(); require(!paused, "Contract is paused"); require(amount > 0, "Amount is zero"); require(amount <= maxMint, "Amount exceeds max mint"); require(supply + amount <= maxSupply, "Max supply reached"); for (uint i = 1; i <= amount; i++) { _safeMint(to, supply + i); } } function airdrop(address to, uint tokenId) external onlyAdmin { require(!paused, "Contract is paused"); require(to != address(0), "Can't airdrop to a zero address"); safeTransferFrom(msg.sender, to, tokenId); emit Airdropped(to, tokenId); } // *************************** // Game management // *************************** // Main function to draw the roadmap prizes and pay the winners function draw() external payable onlyAdmin { require(!paused, "Contract is paused"); releaseAll(); uint[] memory prizes = consumeRoadmapPrizes(totalSupply()); uint nonce = block.difficulty; for (uint i = 0; i < prizes.length; i++) { uint tokenId = randToken(i, nonce); require(tokenId != 0, "Incorrect tokenId"); address winner = ownerOf(tokenId); require(winner != address(0), "Can't pay a zero address"); pay(payable(winner), (prizes[i] * MILLIETHER)); nonce=nonce^uint(keccak256(abi.encodePacked(winner))); emit Winner(tokenId, winner, prizes[i]); } } // Alternative draw method to choose one random winner with a given prize function drawOne(uint milliEther) external payable onlyAdmin { require(!paused, "Contract is paused"); releaseAll(); uint seed = uint(keccak256(abi.encodePacked(block.coinbase))); uint nonce = uint(keccak256(abi.encodePacked(msg.sender))); uint tokenId = randToken(seed, nonce); require(tokenId != 0, "Incorrect tokenId"); address winner = ownerOf(tokenId); require(winner != address(0), "Can't pay a zero address"); pay(payable(winner), (milliEther * MILLIETHER)); emit Winner(tokenId, winner, milliEther); } // *************************** // Internals // *************************** // Initialize the roadmap function initRoadmap() internal onlyAdmin { roadmap[0] = RoadmapStep(1000,2,22000,1); roadmap[1] = RoadmapStep(2000,3,22000,1); roadmap[2] = RoadmapStep(3000,1,44000,1); roadmap[3] = RoadmapStep(4000,1,44000,1); roadmap[4] = RoadmapStep(5000,50,1100,2); roadmap[5] = RoadmapStep(7000,50,1100,2); roadmap[6] = RoadmapStep(7000,10,11000,1); roadmap[7] = RoadmapStep(10000,1,220000,1); roadmap[8] = RoadmapStep(10000,50,2200,1); } // Consume some prizes according to the roadmap // Rule : winnersCount per week and only one prizeValue same amount at a time. function consumeRoadmapPrizes(uint supply) internal onlyAdmin returns (uint[] memory) { uint index = 0; uint[] memory temp = new uint[](16); for (uint i = 0; i < 9; i++) { isPrizeGiven[roadmap[i].prizeValue] = false; } for (uint i = 0; i < roadmap.length; i++) { if (roadmap[i].supply > supply) { break; } if ((roadmap[i].supply <= supply) && (roadmap[i].winnersCount > 0) && !isPrizeGiven[roadmap[i].prizeValue]) { for (uint j = 0; j < Math.min(roadmap[i].winnersToDraw, roadmap[i].winnersCount); j++) { roadmap[i].winnersCount--; temp[index] = roadmap[i].prizeValue; index++; } isPrizeGiven[roadmap[i].prizeValue] = true; } } uint[] memory prizes = new uint[](index); for (uint i = 0; i < index; i++) { prizes[i] = temp[i]; } return prizes; } // Randomly picks a tokenId function randToken(uint seed, uint nonce) internal view onlyAdmin returns(uint) { uint supply = totalSupply(); if (supply > 0) { uint tokenId = randModulus(supply, seed, nonce); if (tokenId > 0) { return tokenId; } } return 0; } // Pays eth amount to an address function pay(address payable to, uint amount) internal onlyAdmin { require(to != address(0), "Can't pay a zero address"); require(address(this).balance >= amount, "No sufficient fund in contract to pay the address"); (bool sent, bytes memory data) = to.call{value: amount}(""); if (sent) { addToReleased(amount); } require(sent, string(abi.encodePacked("Failed to send Ether:", data))); } // Gets a random number function randModulus(uint max, uint seed, uint nonce) internal view returns(uint) { uint blockNumber = block.number-1; if (block.number>(seed % 256)) { blockNumber=block.number-(seed % 256); } uint rand = uint(keccak256(abi.encodePacked( seed^block.timestamp, block.timestamp, msg.data, nonce, msg.sender, blockhash(blockNumber) ) )) % max; return rand+1; } }
randToken
function randToken(uint seed, uint nonce) internal view onlyAdmin returns(uint) { uint supply = totalSupply(); if (supply > 0) { uint tokenId = randModulus(supply, seed, nonce); if (tokenId > 0) { return tokenId; } } return 0; }
// Randomly picks a tokenId
LineComment
v0.8.7+commit.e28d00a7
MIT
ipfs://414d9951eb094e9f3eecc45ff7dcf1c7de317858d1ad8616b1355e70b4b69e2c
{ "func_code_index": [ 13849, 14179 ] }
58,695
MegaMilionsGangstarApes
MegaMilionsGangstarApes.sol
0x3af32fd45224c502469af10e8fff285c18a978bc
Solidity
MegaMilionsGangstarApes
contract MegaMilionsGangstarApes is ERC721, ERC721Enumerable, ERC721URIStorage, ERC2981ContractWideRoyalties, Ownable, PaymentSplitter { using Counters for Counters.Counter; using Strings for uint; using Math for uint; using SafeMath for uint; enum PriceType{ PROMO, FULL } //{ 0, 1 } struct Promo { uint startTime; uint duration; } // Mappings mapping(address => bool) public whitelisted; mapping(address => uint) public promos; mapping(address => bool) public admins; // Default values uint internal constant MILLIETHER = 1e15; //0.001 ETHER = 1,000,000,000,000,000 WEI uint internal promoPrice = 0.1 ether; uint internal fullPrice = 0.3 ether; uint internal maxSupply = 10000; uint internal maxMint = 10; uint internal maxDiscountedMintPerUser = 2; // Vars string private baseURI; bool private paused = false; Promo private promo; // Wallet shares - 50% of revenues shared to team address private DP = 0xcd70Dc892F240D50b7D46CE120dc75c3243E72ab; address private RG = 0x39c34674EEC3AE5F1E9a6Ee899CB85f11a55D990; address private JH = 0xD484E2745d27FA62E6ab0396fd46e0A3E3A00eFc; address private LH = 0xB2CEe0977Bbb0446B358E0Cb3de69e10EdC5eDA3; address private EA = 0x3a4FF805cD9C063f06a0263EEa99F531FAa13B91; address private AG = 0x79f6E63B4D593F3794019A4FEFB52196C602E037; address private JP = 0xd7EE8aF7a902bb208878E50863220e2872b73992; address private MR = 0xaFBC38a36Cb173d75735f3f781e9133939e99888; address private AF = 0x7a2DD031a02Fd595C7BCb0A278A4518daB31AF8d; address private MA = 0xEe3642cb451F6f4ec5C6dd6699fFE69F2D07921E; uint[] private _shares = [ 675, 675, 11250, 6750, 9865, 6750, 7865, 270, 675, 5225 ]; address[] private _team = [ DP, RG, JH, LH, EA, AG, JP, MR, AF, MA ]; // Game struct RoadmapStep { uint64 supply; uint64 winnersCount; uint64 prizeValue; uint64 winnersToDraw; } uint private drawIndex = 0; RoadmapStep[9] private roadmap; mapping(uint => bool) internal isPrizeGiven; // Modifiers modifier onlyAdmin() { require(address(this) == _msgSender() || owner() == _msgSender() || admins[msg.sender], "Not admin"); _; } // Emitters event BaseURIChanged(string tokenBaseURI); event TicketPriceChanged(PriceType priceType, uint price); event MaxMintAmountChanged(uint amount); event MaxDiscountedMintPerUser(uint mintPerUser); event Paused(bool paused); event PromoChanged(uint startTime, uint duration); event Airdropped(address to, uint tokenId); event Winner(uint token, address winner, uint value); event Log(string error); constructor() ERC721("Mega Millions Gangstar Apes", "MMGA") PaymentSplitter(_team, _shares) { //set default admins admins[DP] = true; admins[RG] = true; initRoadmap(); //if ERC2981 supported _setRoyalties(address(this), 1000); //10% } // *************************** // Overrides // *************************** function _beforeTokenTransfer(address from, address to, uint tokenId) internal override(ERC721, ERC721Enumerable) { super._beforeTokenTransfer(from, to, tokenId); } function supportsInterface(bytes4 interfaceId) public view override(ERC721, ERC721Enumerable, ERC2981Base) returns (bool) { return super.supportsInterface(interfaceId); } function _burn(uint _tokenId) internal override(ERC721, ERC721URIStorage) { super._burn(_tokenId); } function burn(uint _tokenId) external onlyAdmin { _burn(_tokenId); maxSupply = maxSupply - 1; } // *************************** // Admins management by owner // *************************** function enableAdmin(address addr) external onlyOwner { admins[addr] = true; } function disableAdmin(address addr) external onlyOwner { require(addr != owner(), "Can't disable owner"); admins[addr] = false; } // *************************** // Release & withdraw // *************************** function releaseAll() public onlyAdmin { for (uint i = 0; i < _team.length; i++) { address member = _team[i]; try this.release(payable(member)) {} catch Error(string memory revertReason) { emit Log(revertReason); } catch (bytes memory returnData) { emit Log(string(returnData)); } } } function withdraw() external onlyAdmin { releaseAll(); pay(payable(owner()), address(this).balance); } // *************************** // Contract management // *************************** function pause(bool newState) external onlyAdmin { paused = newState; emit Paused(newState); } function addWhitelistedUsers(address[] calldata users) external onlyAdmin { for (uint i = 0; i < users.length; i++) { require(users[i] != address(0), "Can't add a zero address"); if (whitelisted[users[i]] == false) { whitelisted[users[i]] = true; } } } function removeWhitelistedUsers(address[] calldata users) external onlyAdmin { for (uint i = 0; i < users.length; i++) { require(users[i] != address(0), "Can't remove a zero address"); if (whitelisted[users[i]] == true) { whitelisted[users[i]] = false; } } } // Duration in seconds function startPromo(uint duration) external onlyAdmin { uint startTime = block.timestamp; promo = Promo(startTime, duration); emit PromoChanged(startTime, duration); } // *************************** // URI management (Reveal) // *************************** function _baseURI() internal view virtual override returns (string memory) { return baseURI; } function setBaseURI(string memory newBaseURI) external onlyAdmin { baseURI = newBaseURI; emit BaseURIChanged(newBaseURI); } function setTokenURI(uint _tokenId, string memory _tokenURI) external onlyAdmin { require(_exists(_tokenId), "URI set of nonexistent token"); _setTokenURI(_tokenId, _tokenURI); } function tokenURI(uint _tokenId) public view override(ERC721, ERC721URIStorage) returns (string memory) { return super.tokenURI(_tokenId); } // *************************** // Promo & price management // *************************** function setPrice(PriceType priceType, uint price) external onlyAdmin { require(price > 0, "Zero price"); if (priceType == PriceType.PROMO) { promoPrice = price; } else if (priceType == PriceType.FULL) { fullPrice = price; } emit TicketPriceChanged(priceType, price); } function setMaxMintAmount(uint amount) external onlyAdmin { maxMint = amount; emit MaxMintAmountChanged(amount); } function setMaxDiscountedMintPerUser(uint mintPerUser) external onlyAdmin { maxDiscountedMintPerUser = mintPerUser; emit MaxDiscountedMintPerUser(mintPerUser); } function isPromo() public view returns (bool) { return (promo.startTime > 0 && block.timestamp >= promo.startTime && block.timestamp <= (promo.startTime + promo.duration)); } // Dynamically gets the token price according to promo, whitelist and msg.sender function getPrice() public view returns (uint) { uint price = fullPrice; if (admins[msg.sender] == true) { price = 0; } else if ((isPromo() || whitelisted[msg.sender] == true) && promos[msg.sender] < maxDiscountedMintPerUser) { price = promoPrice; } return price; } // *************************** // Mint, Gift & Airdrop // *************************** function mint(address to, uint amount) external payable { uint supply = totalSupply(); bool discounted = (getPrice() == promoPrice); require(!paused, "Contract is paused"); require(amount > 0, "Amount is zero"); require(amount <= maxMint, "Amount exceeds max mint"); require(supply + amount <= maxSupply, "Max supply reached"); if (admins[msg.sender] != true) { if (discounted) { require(promos[to] + amount <= maxDiscountedMintPerUser, "Max discounted NFT exceeded for this user"); } require(getPrice().mul(amount) == msg.value, "Ether value sent is not correct"); } for (uint i = 1; i <= amount; i++) { _safeMint(to, supply + i); if(discounted) { promos[to] = promos[to] + 1; } } } function gift(address to, uint amount) external onlyAdmin { uint supply = totalSupply(); require(!paused, "Contract is paused"); require(amount > 0, "Amount is zero"); require(amount <= maxMint, "Amount exceeds max mint"); require(supply + amount <= maxSupply, "Max supply reached"); for (uint i = 1; i <= amount; i++) { _safeMint(to, supply + i); } } function airdrop(address to, uint tokenId) external onlyAdmin { require(!paused, "Contract is paused"); require(to != address(0), "Can't airdrop to a zero address"); safeTransferFrom(msg.sender, to, tokenId); emit Airdropped(to, tokenId); } // *************************** // Game management // *************************** // Main function to draw the roadmap prizes and pay the winners function draw() external payable onlyAdmin { require(!paused, "Contract is paused"); releaseAll(); uint[] memory prizes = consumeRoadmapPrizes(totalSupply()); uint nonce = block.difficulty; for (uint i = 0; i < prizes.length; i++) { uint tokenId = randToken(i, nonce); require(tokenId != 0, "Incorrect tokenId"); address winner = ownerOf(tokenId); require(winner != address(0), "Can't pay a zero address"); pay(payable(winner), (prizes[i] * MILLIETHER)); nonce=nonce^uint(keccak256(abi.encodePacked(winner))); emit Winner(tokenId, winner, prizes[i]); } } // Alternative draw method to choose one random winner with a given prize function drawOne(uint milliEther) external payable onlyAdmin { require(!paused, "Contract is paused"); releaseAll(); uint seed = uint(keccak256(abi.encodePacked(block.coinbase))); uint nonce = uint(keccak256(abi.encodePacked(msg.sender))); uint tokenId = randToken(seed, nonce); require(tokenId != 0, "Incorrect tokenId"); address winner = ownerOf(tokenId); require(winner != address(0), "Can't pay a zero address"); pay(payable(winner), (milliEther * MILLIETHER)); emit Winner(tokenId, winner, milliEther); } // *************************** // Internals // *************************** // Initialize the roadmap function initRoadmap() internal onlyAdmin { roadmap[0] = RoadmapStep(1000,2,22000,1); roadmap[1] = RoadmapStep(2000,3,22000,1); roadmap[2] = RoadmapStep(3000,1,44000,1); roadmap[3] = RoadmapStep(4000,1,44000,1); roadmap[4] = RoadmapStep(5000,50,1100,2); roadmap[5] = RoadmapStep(7000,50,1100,2); roadmap[6] = RoadmapStep(7000,10,11000,1); roadmap[7] = RoadmapStep(10000,1,220000,1); roadmap[8] = RoadmapStep(10000,50,2200,1); } // Consume some prizes according to the roadmap // Rule : winnersCount per week and only one prizeValue same amount at a time. function consumeRoadmapPrizes(uint supply) internal onlyAdmin returns (uint[] memory) { uint index = 0; uint[] memory temp = new uint[](16); for (uint i = 0; i < 9; i++) { isPrizeGiven[roadmap[i].prizeValue] = false; } for (uint i = 0; i < roadmap.length; i++) { if (roadmap[i].supply > supply) { break; } if ((roadmap[i].supply <= supply) && (roadmap[i].winnersCount > 0) && !isPrizeGiven[roadmap[i].prizeValue]) { for (uint j = 0; j < Math.min(roadmap[i].winnersToDraw, roadmap[i].winnersCount); j++) { roadmap[i].winnersCount--; temp[index] = roadmap[i].prizeValue; index++; } isPrizeGiven[roadmap[i].prizeValue] = true; } } uint[] memory prizes = new uint[](index); for (uint i = 0; i < index; i++) { prizes[i] = temp[i]; } return prizes; } // Randomly picks a tokenId function randToken(uint seed, uint nonce) internal view onlyAdmin returns(uint) { uint supply = totalSupply(); if (supply > 0) { uint tokenId = randModulus(supply, seed, nonce); if (tokenId > 0) { return tokenId; } } return 0; } // Pays eth amount to an address function pay(address payable to, uint amount) internal onlyAdmin { require(to != address(0), "Can't pay a zero address"); require(address(this).balance >= amount, "No sufficient fund in contract to pay the address"); (bool sent, bytes memory data) = to.call{value: amount}(""); if (sent) { addToReleased(amount); } require(sent, string(abi.encodePacked("Failed to send Ether:", data))); } // Gets a random number function randModulus(uint max, uint seed, uint nonce) internal view returns(uint) { uint blockNumber = block.number-1; if (block.number>(seed % 256)) { blockNumber=block.number-(seed % 256); } uint rand = uint(keccak256(abi.encodePacked( seed^block.timestamp, block.timestamp, msg.data, nonce, msg.sender, blockhash(blockNumber) ) )) % max; return rand+1; } }
pay
function pay(address payable to, uint amount) internal onlyAdmin { require(to != address(0), "Can't pay a zero address"); require(address(this).balance >= amount, "No sufficient fund in contract to pay the address"); (bool sent, bytes memory data) = to.call{value: amount}(""); if (sent) { addToReleased(amount); } require(sent, string(abi.encodePacked("Failed to send Ether:", data))); }
// Pays eth amount to an address
LineComment
v0.8.7+commit.e28d00a7
MIT
ipfs://414d9951eb094e9f3eecc45ff7dcf1c7de317858d1ad8616b1355e70b4b69e2c
{ "func_code_index": [ 14224, 14690 ] }
58,696
MegaMilionsGangstarApes
MegaMilionsGangstarApes.sol
0x3af32fd45224c502469af10e8fff285c18a978bc
Solidity
MegaMilionsGangstarApes
contract MegaMilionsGangstarApes is ERC721, ERC721Enumerable, ERC721URIStorage, ERC2981ContractWideRoyalties, Ownable, PaymentSplitter { using Counters for Counters.Counter; using Strings for uint; using Math for uint; using SafeMath for uint; enum PriceType{ PROMO, FULL } //{ 0, 1 } struct Promo { uint startTime; uint duration; } // Mappings mapping(address => bool) public whitelisted; mapping(address => uint) public promos; mapping(address => bool) public admins; // Default values uint internal constant MILLIETHER = 1e15; //0.001 ETHER = 1,000,000,000,000,000 WEI uint internal promoPrice = 0.1 ether; uint internal fullPrice = 0.3 ether; uint internal maxSupply = 10000; uint internal maxMint = 10; uint internal maxDiscountedMintPerUser = 2; // Vars string private baseURI; bool private paused = false; Promo private promo; // Wallet shares - 50% of revenues shared to team address private DP = 0xcd70Dc892F240D50b7D46CE120dc75c3243E72ab; address private RG = 0x39c34674EEC3AE5F1E9a6Ee899CB85f11a55D990; address private JH = 0xD484E2745d27FA62E6ab0396fd46e0A3E3A00eFc; address private LH = 0xB2CEe0977Bbb0446B358E0Cb3de69e10EdC5eDA3; address private EA = 0x3a4FF805cD9C063f06a0263EEa99F531FAa13B91; address private AG = 0x79f6E63B4D593F3794019A4FEFB52196C602E037; address private JP = 0xd7EE8aF7a902bb208878E50863220e2872b73992; address private MR = 0xaFBC38a36Cb173d75735f3f781e9133939e99888; address private AF = 0x7a2DD031a02Fd595C7BCb0A278A4518daB31AF8d; address private MA = 0xEe3642cb451F6f4ec5C6dd6699fFE69F2D07921E; uint[] private _shares = [ 675, 675, 11250, 6750, 9865, 6750, 7865, 270, 675, 5225 ]; address[] private _team = [ DP, RG, JH, LH, EA, AG, JP, MR, AF, MA ]; // Game struct RoadmapStep { uint64 supply; uint64 winnersCount; uint64 prizeValue; uint64 winnersToDraw; } uint private drawIndex = 0; RoadmapStep[9] private roadmap; mapping(uint => bool) internal isPrizeGiven; // Modifiers modifier onlyAdmin() { require(address(this) == _msgSender() || owner() == _msgSender() || admins[msg.sender], "Not admin"); _; } // Emitters event BaseURIChanged(string tokenBaseURI); event TicketPriceChanged(PriceType priceType, uint price); event MaxMintAmountChanged(uint amount); event MaxDiscountedMintPerUser(uint mintPerUser); event Paused(bool paused); event PromoChanged(uint startTime, uint duration); event Airdropped(address to, uint tokenId); event Winner(uint token, address winner, uint value); event Log(string error); constructor() ERC721("Mega Millions Gangstar Apes", "MMGA") PaymentSplitter(_team, _shares) { //set default admins admins[DP] = true; admins[RG] = true; initRoadmap(); //if ERC2981 supported _setRoyalties(address(this), 1000); //10% } // *************************** // Overrides // *************************** function _beforeTokenTransfer(address from, address to, uint tokenId) internal override(ERC721, ERC721Enumerable) { super._beforeTokenTransfer(from, to, tokenId); } function supportsInterface(bytes4 interfaceId) public view override(ERC721, ERC721Enumerable, ERC2981Base) returns (bool) { return super.supportsInterface(interfaceId); } function _burn(uint _tokenId) internal override(ERC721, ERC721URIStorage) { super._burn(_tokenId); } function burn(uint _tokenId) external onlyAdmin { _burn(_tokenId); maxSupply = maxSupply - 1; } // *************************** // Admins management by owner // *************************** function enableAdmin(address addr) external onlyOwner { admins[addr] = true; } function disableAdmin(address addr) external onlyOwner { require(addr != owner(), "Can't disable owner"); admins[addr] = false; } // *************************** // Release & withdraw // *************************** function releaseAll() public onlyAdmin { for (uint i = 0; i < _team.length; i++) { address member = _team[i]; try this.release(payable(member)) {} catch Error(string memory revertReason) { emit Log(revertReason); } catch (bytes memory returnData) { emit Log(string(returnData)); } } } function withdraw() external onlyAdmin { releaseAll(); pay(payable(owner()), address(this).balance); } // *************************** // Contract management // *************************** function pause(bool newState) external onlyAdmin { paused = newState; emit Paused(newState); } function addWhitelistedUsers(address[] calldata users) external onlyAdmin { for (uint i = 0; i < users.length; i++) { require(users[i] != address(0), "Can't add a zero address"); if (whitelisted[users[i]] == false) { whitelisted[users[i]] = true; } } } function removeWhitelistedUsers(address[] calldata users) external onlyAdmin { for (uint i = 0; i < users.length; i++) { require(users[i] != address(0), "Can't remove a zero address"); if (whitelisted[users[i]] == true) { whitelisted[users[i]] = false; } } } // Duration in seconds function startPromo(uint duration) external onlyAdmin { uint startTime = block.timestamp; promo = Promo(startTime, duration); emit PromoChanged(startTime, duration); } // *************************** // URI management (Reveal) // *************************** function _baseURI() internal view virtual override returns (string memory) { return baseURI; } function setBaseURI(string memory newBaseURI) external onlyAdmin { baseURI = newBaseURI; emit BaseURIChanged(newBaseURI); } function setTokenURI(uint _tokenId, string memory _tokenURI) external onlyAdmin { require(_exists(_tokenId), "URI set of nonexistent token"); _setTokenURI(_tokenId, _tokenURI); } function tokenURI(uint _tokenId) public view override(ERC721, ERC721URIStorage) returns (string memory) { return super.tokenURI(_tokenId); } // *************************** // Promo & price management // *************************** function setPrice(PriceType priceType, uint price) external onlyAdmin { require(price > 0, "Zero price"); if (priceType == PriceType.PROMO) { promoPrice = price; } else if (priceType == PriceType.FULL) { fullPrice = price; } emit TicketPriceChanged(priceType, price); } function setMaxMintAmount(uint amount) external onlyAdmin { maxMint = amount; emit MaxMintAmountChanged(amount); } function setMaxDiscountedMintPerUser(uint mintPerUser) external onlyAdmin { maxDiscountedMintPerUser = mintPerUser; emit MaxDiscountedMintPerUser(mintPerUser); } function isPromo() public view returns (bool) { return (promo.startTime > 0 && block.timestamp >= promo.startTime && block.timestamp <= (promo.startTime + promo.duration)); } // Dynamically gets the token price according to promo, whitelist and msg.sender function getPrice() public view returns (uint) { uint price = fullPrice; if (admins[msg.sender] == true) { price = 0; } else if ((isPromo() || whitelisted[msg.sender] == true) && promos[msg.sender] < maxDiscountedMintPerUser) { price = promoPrice; } return price; } // *************************** // Mint, Gift & Airdrop // *************************** function mint(address to, uint amount) external payable { uint supply = totalSupply(); bool discounted = (getPrice() == promoPrice); require(!paused, "Contract is paused"); require(amount > 0, "Amount is zero"); require(amount <= maxMint, "Amount exceeds max mint"); require(supply + amount <= maxSupply, "Max supply reached"); if (admins[msg.sender] != true) { if (discounted) { require(promos[to] + amount <= maxDiscountedMintPerUser, "Max discounted NFT exceeded for this user"); } require(getPrice().mul(amount) == msg.value, "Ether value sent is not correct"); } for (uint i = 1; i <= amount; i++) { _safeMint(to, supply + i); if(discounted) { promos[to] = promos[to] + 1; } } } function gift(address to, uint amount) external onlyAdmin { uint supply = totalSupply(); require(!paused, "Contract is paused"); require(amount > 0, "Amount is zero"); require(amount <= maxMint, "Amount exceeds max mint"); require(supply + amount <= maxSupply, "Max supply reached"); for (uint i = 1; i <= amount; i++) { _safeMint(to, supply + i); } } function airdrop(address to, uint tokenId) external onlyAdmin { require(!paused, "Contract is paused"); require(to != address(0), "Can't airdrop to a zero address"); safeTransferFrom(msg.sender, to, tokenId); emit Airdropped(to, tokenId); } // *************************** // Game management // *************************** // Main function to draw the roadmap prizes and pay the winners function draw() external payable onlyAdmin { require(!paused, "Contract is paused"); releaseAll(); uint[] memory prizes = consumeRoadmapPrizes(totalSupply()); uint nonce = block.difficulty; for (uint i = 0; i < prizes.length; i++) { uint tokenId = randToken(i, nonce); require(tokenId != 0, "Incorrect tokenId"); address winner = ownerOf(tokenId); require(winner != address(0), "Can't pay a zero address"); pay(payable(winner), (prizes[i] * MILLIETHER)); nonce=nonce^uint(keccak256(abi.encodePacked(winner))); emit Winner(tokenId, winner, prizes[i]); } } // Alternative draw method to choose one random winner with a given prize function drawOne(uint milliEther) external payable onlyAdmin { require(!paused, "Contract is paused"); releaseAll(); uint seed = uint(keccak256(abi.encodePacked(block.coinbase))); uint nonce = uint(keccak256(abi.encodePacked(msg.sender))); uint tokenId = randToken(seed, nonce); require(tokenId != 0, "Incorrect tokenId"); address winner = ownerOf(tokenId); require(winner != address(0), "Can't pay a zero address"); pay(payable(winner), (milliEther * MILLIETHER)); emit Winner(tokenId, winner, milliEther); } // *************************** // Internals // *************************** // Initialize the roadmap function initRoadmap() internal onlyAdmin { roadmap[0] = RoadmapStep(1000,2,22000,1); roadmap[1] = RoadmapStep(2000,3,22000,1); roadmap[2] = RoadmapStep(3000,1,44000,1); roadmap[3] = RoadmapStep(4000,1,44000,1); roadmap[4] = RoadmapStep(5000,50,1100,2); roadmap[5] = RoadmapStep(7000,50,1100,2); roadmap[6] = RoadmapStep(7000,10,11000,1); roadmap[7] = RoadmapStep(10000,1,220000,1); roadmap[8] = RoadmapStep(10000,50,2200,1); } // Consume some prizes according to the roadmap // Rule : winnersCount per week and only one prizeValue same amount at a time. function consumeRoadmapPrizes(uint supply) internal onlyAdmin returns (uint[] memory) { uint index = 0; uint[] memory temp = new uint[](16); for (uint i = 0; i < 9; i++) { isPrizeGiven[roadmap[i].prizeValue] = false; } for (uint i = 0; i < roadmap.length; i++) { if (roadmap[i].supply > supply) { break; } if ((roadmap[i].supply <= supply) && (roadmap[i].winnersCount > 0) && !isPrizeGiven[roadmap[i].prizeValue]) { for (uint j = 0; j < Math.min(roadmap[i].winnersToDraw, roadmap[i].winnersCount); j++) { roadmap[i].winnersCount--; temp[index] = roadmap[i].prizeValue; index++; } isPrizeGiven[roadmap[i].prizeValue] = true; } } uint[] memory prizes = new uint[](index); for (uint i = 0; i < index; i++) { prizes[i] = temp[i]; } return prizes; } // Randomly picks a tokenId function randToken(uint seed, uint nonce) internal view onlyAdmin returns(uint) { uint supply = totalSupply(); if (supply > 0) { uint tokenId = randModulus(supply, seed, nonce); if (tokenId > 0) { return tokenId; } } return 0; } // Pays eth amount to an address function pay(address payable to, uint amount) internal onlyAdmin { require(to != address(0), "Can't pay a zero address"); require(address(this).balance >= amount, "No sufficient fund in contract to pay the address"); (bool sent, bytes memory data) = to.call{value: amount}(""); if (sent) { addToReleased(amount); } require(sent, string(abi.encodePacked("Failed to send Ether:", data))); } // Gets a random number function randModulus(uint max, uint seed, uint nonce) internal view returns(uint) { uint blockNumber = block.number-1; if (block.number>(seed % 256)) { blockNumber=block.number-(seed % 256); } uint rand = uint(keccak256(abi.encodePacked( seed^block.timestamp, block.timestamp, msg.data, nonce, msg.sender, blockhash(blockNumber) ) )) % max; return rand+1; } }
randModulus
function randModulus(uint max, uint seed, uint nonce) internal view returns(uint) { uint blockNumber = block.number-1; if (block.number>(seed % 256)) { blockNumber=block.number-(seed % 256); } uint rand = uint(keccak256(abi.encodePacked( seed^block.timestamp, block.timestamp, msg.data, nonce, msg.sender, blockhash(blockNumber) ) )) % max; return rand+1; }
// Gets a random number
LineComment
v0.8.7+commit.e28d00a7
MIT
ipfs://414d9951eb094e9f3eecc45ff7dcf1c7de317858d1ad8616b1355e70b4b69e2c
{ "func_code_index": [ 14726, 15253 ] }
58,697
STEST2Token
STEST2Token.sol
0x7bcc0f6b153c227527ff74d1ab33610b51629461
Solidity
StandardToken
contract StandardToken is ERC20, SafeMath { /* Token supply got increased and a new owner received these tokens */ event Minted(address receiver, uint amount); /* Actual balances of token holders */ mapping(address => uint) balances; /* approve() allowances */ mapping (address => mapping (address => uint)) allowed; /* Interface declaration */ function isToken() public constant returns (bool Yes) { return true; } function transfer(address _to, uint _value) returns (bool success) { balances[msg.sender] = safeSub(balances[msg.sender], _value); balances[_to] = safeAdd(balances[_to], _value); emit Transfer(msg.sender, _to, _value); return true; } function transferFrom(address _from, address _to, uint _value) returns (bool success) { uint _allowance = allowed[_from][msg.sender]; balances[_to] = safeAdd(balances[_to], _value); balances[_from] = safeSub(balances[_from], _value); allowed[_from][msg.sender] = safeSub(_allowance, _value); emit Transfer(_from, _to, _value); return true; } function balanceOf(address _address) constant returns (uint balance) { return balances[_address]; } function approve(address _spender, uint _value) returns (bool success) { // To change the approve amount you first have to reduce the addresses` // allowance to zero by calling `approve(_spender, 0)` if it is not // already 0 to mitigate the race condition described here: // https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 require((_value == 0) || (allowed[msg.sender][_spender] == 0)); allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } function allowance(address _owner, address _spender) constant returns (uint remaining) { return allowed[_owner][_spender]; } }
isToken
function isToken() public constant returns (bool Yes) { return true; }
/* Interface declaration */
Comment
v0.4.26+commit.4563c3fc
None
bzzr://33f0be552ed69acbe733eb14c1d29a38016f7e3e2ac7014d7143c43a457e22c3
{ "func_code_index": [ 375, 456 ] }
58,698
STEST2Token
STEST2Token.sol
0x7bcc0f6b153c227527ff74d1ab33610b51629461
Solidity
STEST2Token
contract STEST2Token is StandardToken { string public name = "STEST2 Token"; string public symbol = "STEST2"; uint public totalSupply = 18000000; //Addresses that are allowed to transfer tokens mapping (address => bool) public allowedTransfer; //Technical variables to store states bool public TransferAllowed = true;//Token transfers are blocked //Technical variables to store statistical data uint public StatsMinted = 0;//Minted tokens amount uint public StatsTotal = 0;//Overall tokens amount //Event logs event Buy(address indexed sender, uint eth, uint tokens, uint bonus);//Tokens purchased event Mint(address indexed from, uint tokens);// This notifies clients about the amount minted event Burn(address indexed from, uint tokens);// This notifies clients about the amount burnt address public owner = 0x0;//Admin actions address public minter = 0x0;//Minter tokens function STEST2Token(address _owner, address _minter) payable { owner = _owner; minter = _minter; balances[owner] = 0; balances[minter] = 0; allowedTransfer[owner] = true; allowedTransfer[minter] = true; } modifier onlyOwner() { require(msg.sender == owner); _; } //Allow or prohibit token transfers function setTransferAllowance(bool _allowance) external onlyOwner { TransferAllowed = _allowance; } // Send `_amount` of tokens to `_target` function mintTokens(address _target, uint _amount) external returns (bool) { require(msg.sender == owner || msg.sender == minter); require(_amount > 0);//Number of tokens must be greater than 0 uint amount=_amount; require(safeAdd(StatsTotal, amount) <= totalSupply);//The amount of tokens cannot be greater than Total supply balances[_target] = safeAdd(balances[_target], amount); StatsMinted = safeAdd(StatsMinted, amount);//Update number of tokens minted StatsTotal = safeAdd(StatsTotal, amount);//Update total number of tokens emit Transfer(0, this, amount); emit Transfer(this, _target, amount); emit Mint(_target, amount); return true; } // Decrease user balance function decreaseTokens(address _target, uint _amount) external returns (bool) { require(msg.sender == owner || msg.sender == minter); require(_amount > 0);//Number of tokens must be greater than 0 uint amount=_amount; balances[_target] = safeSub(balances[_target], amount); StatsMinted = safeSub(StatsMinted, amount);//Update number of tokens minted StatsTotal = safeSub(StatsTotal, amount);//Update total number of tokens emit Transfer(_target, 0, amount); emit Burn(_target, amount); return true; } // Allow `_target` make token tranfers function allowTransfer(address _target, bool _allow) external onlyOwner { allowedTransfer[_target] = _allow; } function transfer(address _to, uint _value) returns (bool success) { //Forbid token transfers if(!TransferAllowed){ require(allowedTransfer[msg.sender]); } return super.transfer(_to, _value); } function transferFrom(address _from, address _to, uint _value) returns (bool success) { //Forbid token transfers if(!TransferAllowed){ require(allowedTransfer[msg.sender]); } return super.transferFrom(_from, _to, _value); } //Change owner function changeOwner(address _to) external onlyOwner() { balances[_to] = balances[owner]; balances[owner] = 0; owner = _to; } //Change minter function changeMinter(address _to) external onlyOwner() { balances[_to] = balances[minter]; balances[minter] = 0; minter = _to; } }
STEST2Token
function STEST2Token(address _owner, address _minter) payable { owner = _owner; minter = _minter; balances[owner] = 0; balances[minter] = 0; allowedTransfer[owner] = true; allowedTransfer[minter] = true; }
//Minter tokens
LineComment
v0.4.26+commit.4563c3fc
None
bzzr://33f0be552ed69acbe733eb14c1d29a38016f7e3e2ac7014d7143c43a457e22c3
{ "func_code_index": [ 971, 1260 ] }
58,699
STEST2Token
STEST2Token.sol
0x7bcc0f6b153c227527ff74d1ab33610b51629461
Solidity
STEST2Token
contract STEST2Token is StandardToken { string public name = "STEST2 Token"; string public symbol = "STEST2"; uint public totalSupply = 18000000; //Addresses that are allowed to transfer tokens mapping (address => bool) public allowedTransfer; //Technical variables to store states bool public TransferAllowed = true;//Token transfers are blocked //Technical variables to store statistical data uint public StatsMinted = 0;//Minted tokens amount uint public StatsTotal = 0;//Overall tokens amount //Event logs event Buy(address indexed sender, uint eth, uint tokens, uint bonus);//Tokens purchased event Mint(address indexed from, uint tokens);// This notifies clients about the amount minted event Burn(address indexed from, uint tokens);// This notifies clients about the amount burnt address public owner = 0x0;//Admin actions address public minter = 0x0;//Minter tokens function STEST2Token(address _owner, address _minter) payable { owner = _owner; minter = _minter; balances[owner] = 0; balances[minter] = 0; allowedTransfer[owner] = true; allowedTransfer[minter] = true; } modifier onlyOwner() { require(msg.sender == owner); _; } //Allow or prohibit token transfers function setTransferAllowance(bool _allowance) external onlyOwner { TransferAllowed = _allowance; } // Send `_amount` of tokens to `_target` function mintTokens(address _target, uint _amount) external returns (bool) { require(msg.sender == owner || msg.sender == minter); require(_amount > 0);//Number of tokens must be greater than 0 uint amount=_amount; require(safeAdd(StatsTotal, amount) <= totalSupply);//The amount of tokens cannot be greater than Total supply balances[_target] = safeAdd(balances[_target], amount); StatsMinted = safeAdd(StatsMinted, amount);//Update number of tokens minted StatsTotal = safeAdd(StatsTotal, amount);//Update total number of tokens emit Transfer(0, this, amount); emit Transfer(this, _target, amount); emit Mint(_target, amount); return true; } // Decrease user balance function decreaseTokens(address _target, uint _amount) external returns (bool) { require(msg.sender == owner || msg.sender == minter); require(_amount > 0);//Number of tokens must be greater than 0 uint amount=_amount; balances[_target] = safeSub(balances[_target], amount); StatsMinted = safeSub(StatsMinted, amount);//Update number of tokens minted StatsTotal = safeSub(StatsTotal, amount);//Update total number of tokens emit Transfer(_target, 0, amount); emit Burn(_target, amount); return true; } // Allow `_target` make token tranfers function allowTransfer(address _target, bool _allow) external onlyOwner { allowedTransfer[_target] = _allow; } function transfer(address _to, uint _value) returns (bool success) { //Forbid token transfers if(!TransferAllowed){ require(allowedTransfer[msg.sender]); } return super.transfer(_to, _value); } function transferFrom(address _from, address _to, uint _value) returns (bool success) { //Forbid token transfers if(!TransferAllowed){ require(allowedTransfer[msg.sender]); } return super.transferFrom(_from, _to, _value); } //Change owner function changeOwner(address _to) external onlyOwner() { balances[_to] = balances[owner]; balances[owner] = 0; owner = _to; } //Change minter function changeMinter(address _to) external onlyOwner() { balances[_to] = balances[minter]; balances[minter] = 0; minter = _to; } }
setTransferAllowance
function setTransferAllowance(bool _allowance) external onlyOwner { TransferAllowed = _allowance; }
//Allow or prohibit token transfers
LineComment
v0.4.26+commit.4563c3fc
None
bzzr://33f0be552ed69acbe733eb14c1d29a38016f7e3e2ac7014d7143c43a457e22c3
{ "func_code_index": [ 1396, 1514 ] }
58,700
STEST2Token
STEST2Token.sol
0x7bcc0f6b153c227527ff74d1ab33610b51629461
Solidity
STEST2Token
contract STEST2Token is StandardToken { string public name = "STEST2 Token"; string public symbol = "STEST2"; uint public totalSupply = 18000000; //Addresses that are allowed to transfer tokens mapping (address => bool) public allowedTransfer; //Technical variables to store states bool public TransferAllowed = true;//Token transfers are blocked //Technical variables to store statistical data uint public StatsMinted = 0;//Minted tokens amount uint public StatsTotal = 0;//Overall tokens amount //Event logs event Buy(address indexed sender, uint eth, uint tokens, uint bonus);//Tokens purchased event Mint(address indexed from, uint tokens);// This notifies clients about the amount minted event Burn(address indexed from, uint tokens);// This notifies clients about the amount burnt address public owner = 0x0;//Admin actions address public minter = 0x0;//Minter tokens function STEST2Token(address _owner, address _minter) payable { owner = _owner; minter = _minter; balances[owner] = 0; balances[minter] = 0; allowedTransfer[owner] = true; allowedTransfer[minter] = true; } modifier onlyOwner() { require(msg.sender == owner); _; } //Allow or prohibit token transfers function setTransferAllowance(bool _allowance) external onlyOwner { TransferAllowed = _allowance; } // Send `_amount` of tokens to `_target` function mintTokens(address _target, uint _amount) external returns (bool) { require(msg.sender == owner || msg.sender == minter); require(_amount > 0);//Number of tokens must be greater than 0 uint amount=_amount; require(safeAdd(StatsTotal, amount) <= totalSupply);//The amount of tokens cannot be greater than Total supply balances[_target] = safeAdd(balances[_target], amount); StatsMinted = safeAdd(StatsMinted, amount);//Update number of tokens minted StatsTotal = safeAdd(StatsTotal, amount);//Update total number of tokens emit Transfer(0, this, amount); emit Transfer(this, _target, amount); emit Mint(_target, amount); return true; } // Decrease user balance function decreaseTokens(address _target, uint _amount) external returns (bool) { require(msg.sender == owner || msg.sender == minter); require(_amount > 0);//Number of tokens must be greater than 0 uint amount=_amount; balances[_target] = safeSub(balances[_target], amount); StatsMinted = safeSub(StatsMinted, amount);//Update number of tokens minted StatsTotal = safeSub(StatsTotal, amount);//Update total number of tokens emit Transfer(_target, 0, amount); emit Burn(_target, amount); return true; } // Allow `_target` make token tranfers function allowTransfer(address _target, bool _allow) external onlyOwner { allowedTransfer[_target] = _allow; } function transfer(address _to, uint _value) returns (bool success) { //Forbid token transfers if(!TransferAllowed){ require(allowedTransfer[msg.sender]); } return super.transfer(_to, _value); } function transferFrom(address _from, address _to, uint _value) returns (bool success) { //Forbid token transfers if(!TransferAllowed){ require(allowedTransfer[msg.sender]); } return super.transferFrom(_from, _to, _value); } //Change owner function changeOwner(address _to) external onlyOwner() { balances[_to] = balances[owner]; balances[owner] = 0; owner = _to; } //Change minter function changeMinter(address _to) external onlyOwner() { balances[_to] = balances[minter]; balances[minter] = 0; minter = _to; } }
mintTokens
function mintTokens(address _target, uint _amount) external returns (bool) { require(msg.sender == owner || msg.sender == minter); require(_amount > 0);//Number of tokens must be greater than 0 uint amount=_amount; require(safeAdd(StatsTotal, amount) <= totalSupply);//The amount of tokens cannot be greater than Total supply balances[_target] = safeAdd(balances[_target], amount); StatsMinted = safeAdd(StatsMinted, amount);//Update number of tokens minted StatsTotal = safeAdd(StatsTotal, amount);//Update total number of tokens emit Transfer(0, this, amount); emit Transfer(this, _target, amount); emit Mint(_target, amount); return true; }
// Send `_amount` of tokens to `_target`
LineComment
v0.4.26+commit.4563c3fc
None
bzzr://33f0be552ed69acbe733eb14c1d29a38016f7e3e2ac7014d7143c43a457e22c3
{ "func_code_index": [ 1567, 2319 ] }
58,701
STEST2Token
STEST2Token.sol
0x7bcc0f6b153c227527ff74d1ab33610b51629461
Solidity
STEST2Token
contract STEST2Token is StandardToken { string public name = "STEST2 Token"; string public symbol = "STEST2"; uint public totalSupply = 18000000; //Addresses that are allowed to transfer tokens mapping (address => bool) public allowedTransfer; //Technical variables to store states bool public TransferAllowed = true;//Token transfers are blocked //Technical variables to store statistical data uint public StatsMinted = 0;//Minted tokens amount uint public StatsTotal = 0;//Overall tokens amount //Event logs event Buy(address indexed sender, uint eth, uint tokens, uint bonus);//Tokens purchased event Mint(address indexed from, uint tokens);// This notifies clients about the amount minted event Burn(address indexed from, uint tokens);// This notifies clients about the amount burnt address public owner = 0x0;//Admin actions address public minter = 0x0;//Minter tokens function STEST2Token(address _owner, address _minter) payable { owner = _owner; minter = _minter; balances[owner] = 0; balances[minter] = 0; allowedTransfer[owner] = true; allowedTransfer[minter] = true; } modifier onlyOwner() { require(msg.sender == owner); _; } //Allow or prohibit token transfers function setTransferAllowance(bool _allowance) external onlyOwner { TransferAllowed = _allowance; } // Send `_amount` of tokens to `_target` function mintTokens(address _target, uint _amount) external returns (bool) { require(msg.sender == owner || msg.sender == minter); require(_amount > 0);//Number of tokens must be greater than 0 uint amount=_amount; require(safeAdd(StatsTotal, amount) <= totalSupply);//The amount of tokens cannot be greater than Total supply balances[_target] = safeAdd(balances[_target], amount); StatsMinted = safeAdd(StatsMinted, amount);//Update number of tokens minted StatsTotal = safeAdd(StatsTotal, amount);//Update total number of tokens emit Transfer(0, this, amount); emit Transfer(this, _target, amount); emit Mint(_target, amount); return true; } // Decrease user balance function decreaseTokens(address _target, uint _amount) external returns (bool) { require(msg.sender == owner || msg.sender == minter); require(_amount > 0);//Number of tokens must be greater than 0 uint amount=_amount; balances[_target] = safeSub(balances[_target], amount); StatsMinted = safeSub(StatsMinted, amount);//Update number of tokens minted StatsTotal = safeSub(StatsTotal, amount);//Update total number of tokens emit Transfer(_target, 0, amount); emit Burn(_target, amount); return true; } // Allow `_target` make token tranfers function allowTransfer(address _target, bool _allow) external onlyOwner { allowedTransfer[_target] = _allow; } function transfer(address _to, uint _value) returns (bool success) { //Forbid token transfers if(!TransferAllowed){ require(allowedTransfer[msg.sender]); } return super.transfer(_to, _value); } function transferFrom(address _from, address _to, uint _value) returns (bool success) { //Forbid token transfers if(!TransferAllowed){ require(allowedTransfer[msg.sender]); } return super.transferFrom(_from, _to, _value); } //Change owner function changeOwner(address _to) external onlyOwner() { balances[_to] = balances[owner]; balances[owner] = 0; owner = _to; } //Change minter function changeMinter(address _to) external onlyOwner() { balances[_to] = balances[minter]; balances[minter] = 0; minter = _to; } }
decreaseTokens
function decreaseTokens(address _target, uint _amount) external returns (bool) { require(msg.sender == owner || msg.sender == minter); require(_amount > 0);//Number of tokens must be greater than 0 uint amount=_amount; balances[_target] = safeSub(balances[_target], amount); StatsMinted = safeSub(StatsMinted, amount);//Update number of tokens minted StatsTotal = safeSub(StatsTotal, amount);//Update total number of tokens emit Transfer(_target, 0, amount); emit Burn(_target, amount); return true; }
// Decrease user balance
LineComment
v0.4.26+commit.4563c3fc
None
bzzr://33f0be552ed69acbe733eb14c1d29a38016f7e3e2ac7014d7143c43a457e22c3
{ "func_code_index": [ 2356, 2948 ] }
58,702
STEST2Token
STEST2Token.sol
0x7bcc0f6b153c227527ff74d1ab33610b51629461
Solidity
STEST2Token
contract STEST2Token is StandardToken { string public name = "STEST2 Token"; string public symbol = "STEST2"; uint public totalSupply = 18000000; //Addresses that are allowed to transfer tokens mapping (address => bool) public allowedTransfer; //Technical variables to store states bool public TransferAllowed = true;//Token transfers are blocked //Technical variables to store statistical data uint public StatsMinted = 0;//Minted tokens amount uint public StatsTotal = 0;//Overall tokens amount //Event logs event Buy(address indexed sender, uint eth, uint tokens, uint bonus);//Tokens purchased event Mint(address indexed from, uint tokens);// This notifies clients about the amount minted event Burn(address indexed from, uint tokens);// This notifies clients about the amount burnt address public owner = 0x0;//Admin actions address public minter = 0x0;//Minter tokens function STEST2Token(address _owner, address _minter) payable { owner = _owner; minter = _minter; balances[owner] = 0; balances[minter] = 0; allowedTransfer[owner] = true; allowedTransfer[minter] = true; } modifier onlyOwner() { require(msg.sender == owner); _; } //Allow or prohibit token transfers function setTransferAllowance(bool _allowance) external onlyOwner { TransferAllowed = _allowance; } // Send `_amount` of tokens to `_target` function mintTokens(address _target, uint _amount) external returns (bool) { require(msg.sender == owner || msg.sender == minter); require(_amount > 0);//Number of tokens must be greater than 0 uint amount=_amount; require(safeAdd(StatsTotal, amount) <= totalSupply);//The amount of tokens cannot be greater than Total supply balances[_target] = safeAdd(balances[_target], amount); StatsMinted = safeAdd(StatsMinted, amount);//Update number of tokens minted StatsTotal = safeAdd(StatsTotal, amount);//Update total number of tokens emit Transfer(0, this, amount); emit Transfer(this, _target, amount); emit Mint(_target, amount); return true; } // Decrease user balance function decreaseTokens(address _target, uint _amount) external returns (bool) { require(msg.sender == owner || msg.sender == minter); require(_amount > 0);//Number of tokens must be greater than 0 uint amount=_amount; balances[_target] = safeSub(balances[_target], amount); StatsMinted = safeSub(StatsMinted, amount);//Update number of tokens minted StatsTotal = safeSub(StatsTotal, amount);//Update total number of tokens emit Transfer(_target, 0, amount); emit Burn(_target, amount); return true; } // Allow `_target` make token tranfers function allowTransfer(address _target, bool _allow) external onlyOwner { allowedTransfer[_target] = _allow; } function transfer(address _to, uint _value) returns (bool success) { //Forbid token transfers if(!TransferAllowed){ require(allowedTransfer[msg.sender]); } return super.transfer(_to, _value); } function transferFrom(address _from, address _to, uint _value) returns (bool success) { //Forbid token transfers if(!TransferAllowed){ require(allowedTransfer[msg.sender]); } return super.transferFrom(_from, _to, _value); } //Change owner function changeOwner(address _to) external onlyOwner() { balances[_to] = balances[owner]; balances[owner] = 0; owner = _to; } //Change minter function changeMinter(address _to) external onlyOwner() { balances[_to] = balances[minter]; balances[minter] = 0; minter = _to; } }
allowTransfer
function allowTransfer(address _target, bool _allow) external onlyOwner { allowedTransfer[_target] = _allow; }
// Allow `_target` make token tranfers
LineComment
v0.4.26+commit.4563c3fc
None
bzzr://33f0be552ed69acbe733eb14c1d29a38016f7e3e2ac7014d7143c43a457e22c3
{ "func_code_index": [ 2999, 3128 ] }
58,703
STEST2Token
STEST2Token.sol
0x7bcc0f6b153c227527ff74d1ab33610b51629461
Solidity
STEST2Token
contract STEST2Token is StandardToken { string public name = "STEST2 Token"; string public symbol = "STEST2"; uint public totalSupply = 18000000; //Addresses that are allowed to transfer tokens mapping (address => bool) public allowedTransfer; //Technical variables to store states bool public TransferAllowed = true;//Token transfers are blocked //Technical variables to store statistical data uint public StatsMinted = 0;//Minted tokens amount uint public StatsTotal = 0;//Overall tokens amount //Event logs event Buy(address indexed sender, uint eth, uint tokens, uint bonus);//Tokens purchased event Mint(address indexed from, uint tokens);// This notifies clients about the amount minted event Burn(address indexed from, uint tokens);// This notifies clients about the amount burnt address public owner = 0x0;//Admin actions address public minter = 0x0;//Minter tokens function STEST2Token(address _owner, address _minter) payable { owner = _owner; minter = _minter; balances[owner] = 0; balances[minter] = 0; allowedTransfer[owner] = true; allowedTransfer[minter] = true; } modifier onlyOwner() { require(msg.sender == owner); _; } //Allow or prohibit token transfers function setTransferAllowance(bool _allowance) external onlyOwner { TransferAllowed = _allowance; } // Send `_amount` of tokens to `_target` function mintTokens(address _target, uint _amount) external returns (bool) { require(msg.sender == owner || msg.sender == minter); require(_amount > 0);//Number of tokens must be greater than 0 uint amount=_amount; require(safeAdd(StatsTotal, amount) <= totalSupply);//The amount of tokens cannot be greater than Total supply balances[_target] = safeAdd(balances[_target], amount); StatsMinted = safeAdd(StatsMinted, amount);//Update number of tokens minted StatsTotal = safeAdd(StatsTotal, amount);//Update total number of tokens emit Transfer(0, this, amount); emit Transfer(this, _target, amount); emit Mint(_target, amount); return true; } // Decrease user balance function decreaseTokens(address _target, uint _amount) external returns (bool) { require(msg.sender == owner || msg.sender == minter); require(_amount > 0);//Number of tokens must be greater than 0 uint amount=_amount; balances[_target] = safeSub(balances[_target], amount); StatsMinted = safeSub(StatsMinted, amount);//Update number of tokens minted StatsTotal = safeSub(StatsTotal, amount);//Update total number of tokens emit Transfer(_target, 0, amount); emit Burn(_target, amount); return true; } // Allow `_target` make token tranfers function allowTransfer(address _target, bool _allow) external onlyOwner { allowedTransfer[_target] = _allow; } function transfer(address _to, uint _value) returns (bool success) { //Forbid token transfers if(!TransferAllowed){ require(allowedTransfer[msg.sender]); } return super.transfer(_to, _value); } function transferFrom(address _from, address _to, uint _value) returns (bool success) { //Forbid token transfers if(!TransferAllowed){ require(allowedTransfer[msg.sender]); } return super.transferFrom(_from, _to, _value); } //Change owner function changeOwner(address _to) external onlyOwner() { balances[_to] = balances[owner]; balances[owner] = 0; owner = _to; } //Change minter function changeMinter(address _to) external onlyOwner() { balances[_to] = balances[minter]; balances[minter] = 0; minter = _to; } }
changeOwner
function changeOwner(address _to) external onlyOwner() { balances[_to] = balances[owner]; balances[owner] = 0; owner = _to; }
//Change owner
LineComment
v0.4.26+commit.4563c3fc
None
bzzr://33f0be552ed69acbe733eb14c1d29a38016f7e3e2ac7014d7143c43a457e22c3
{ "func_code_index": [ 3735, 3897 ] }
58,704
STEST2Token
STEST2Token.sol
0x7bcc0f6b153c227527ff74d1ab33610b51629461
Solidity
STEST2Token
contract STEST2Token is StandardToken { string public name = "STEST2 Token"; string public symbol = "STEST2"; uint public totalSupply = 18000000; //Addresses that are allowed to transfer tokens mapping (address => bool) public allowedTransfer; //Technical variables to store states bool public TransferAllowed = true;//Token transfers are blocked //Technical variables to store statistical data uint public StatsMinted = 0;//Minted tokens amount uint public StatsTotal = 0;//Overall tokens amount //Event logs event Buy(address indexed sender, uint eth, uint tokens, uint bonus);//Tokens purchased event Mint(address indexed from, uint tokens);// This notifies clients about the amount minted event Burn(address indexed from, uint tokens);// This notifies clients about the amount burnt address public owner = 0x0;//Admin actions address public minter = 0x0;//Minter tokens function STEST2Token(address _owner, address _minter) payable { owner = _owner; minter = _minter; balances[owner] = 0; balances[minter] = 0; allowedTransfer[owner] = true; allowedTransfer[minter] = true; } modifier onlyOwner() { require(msg.sender == owner); _; } //Allow or prohibit token transfers function setTransferAllowance(bool _allowance) external onlyOwner { TransferAllowed = _allowance; } // Send `_amount` of tokens to `_target` function mintTokens(address _target, uint _amount) external returns (bool) { require(msg.sender == owner || msg.sender == minter); require(_amount > 0);//Number of tokens must be greater than 0 uint amount=_amount; require(safeAdd(StatsTotal, amount) <= totalSupply);//The amount of tokens cannot be greater than Total supply balances[_target] = safeAdd(balances[_target], amount); StatsMinted = safeAdd(StatsMinted, amount);//Update number of tokens minted StatsTotal = safeAdd(StatsTotal, amount);//Update total number of tokens emit Transfer(0, this, amount); emit Transfer(this, _target, amount); emit Mint(_target, amount); return true; } // Decrease user balance function decreaseTokens(address _target, uint _amount) external returns (bool) { require(msg.sender == owner || msg.sender == minter); require(_amount > 0);//Number of tokens must be greater than 0 uint amount=_amount; balances[_target] = safeSub(balances[_target], amount); StatsMinted = safeSub(StatsMinted, amount);//Update number of tokens minted StatsTotal = safeSub(StatsTotal, amount);//Update total number of tokens emit Transfer(_target, 0, amount); emit Burn(_target, amount); return true; } // Allow `_target` make token tranfers function allowTransfer(address _target, bool _allow) external onlyOwner { allowedTransfer[_target] = _allow; } function transfer(address _to, uint _value) returns (bool success) { //Forbid token transfers if(!TransferAllowed){ require(allowedTransfer[msg.sender]); } return super.transfer(_to, _value); } function transferFrom(address _from, address _to, uint _value) returns (bool success) { //Forbid token transfers if(!TransferAllowed){ require(allowedTransfer[msg.sender]); } return super.transferFrom(_from, _to, _value); } //Change owner function changeOwner(address _to) external onlyOwner() { balances[_to] = balances[owner]; balances[owner] = 0; owner = _to; } //Change minter function changeMinter(address _to) external onlyOwner() { balances[_to] = balances[minter]; balances[minter] = 0; minter = _to; } }
changeMinter
function changeMinter(address _to) external onlyOwner() { balances[_to] = balances[minter]; balances[minter] = 0; minter = _to; }
//Change minter
LineComment
v0.4.26+commit.4563c3fc
None
bzzr://33f0be552ed69acbe733eb14c1d29a38016f7e3e2ac7014d7143c43a457e22c3
{ "func_code_index": [ 3921, 4087 ] }
58,705
Bridge
contracts/interfaces/IBridgeV1.sol
0x27ef066f3a3758ff8ee0cf5b86c7dbc0348f77e2
Solidity
IBridgeV1
interface IBridgeV1 { /** * @dev Initiates a token transfer from the given ledger to another Ethereum-compliant ledger. * @param amount The amount of tokens getting locked and swapped from the ledger * @param swapInAddress The address (on another ledger) to which the tokens are swapped */ function SwapOut(uint256 amount, address swapInAddress) external returns (bool); /** * @dev Initiates a token transfer from the given ledger to another Ethereum-compliant ledger. * @param txHash Transaction hash on the ledger where the swap has beed initiated. * @param to The address to which the tokens are swapped * @param amount The amount of tokens released */ function SwapIn( bytes32 txHash, address to, uint256 amount ) external returns (bool); /** * @dev Emits an event upon the swap out call. * @param swapOutAddress The address of the swap out initiator * @param swapInAddress The address (on another ledger) to which the tokens are swapped * @param amount The amount of tokens getting locked and swapped from the ledger */ event LogSwapOut( address indexed swapOutAddress, address indexed swapInAddress, uint256 amount ); /** * @dev Emits an event upon the swap in call. * @dev Initiates a token transfer from the given ledger to another Ethereum-compliant ledger. * @param txHash Transaction hash on the ledger where the swap has beed initiated. * @param swapInAddress The address to which the tokens are swapped * @param amountSent The amount of tokens released * @param fee The amount of tokens released */ event LogSwapIn( bytes32 indexed txHash, address indexed swapInAddress, uint256 amountSent, uint256 fee ); /** * @dev Emits an event upon changing fee in the contract * @dev Initiates a token transfer from the given ledger to another Ethereum-compliant ledger. * @param oldFee The fee before tx * @param newFee The new fee updated to */ event LogFeeUpdate( uint256 oldFee, uint256 newFee ); /** * @dev Emits an event upon changing fee in the contract * @dev Add liquidity to the bridge. * @param from who deposited * @param amount amount deposited */ event LogLiquidityAdded( address from, uint256 amount ); }
/** * @title IBridgeV1 - Bridge V1 interface * @notice Interface for the Equalizer Bridge V1 * @author Equalizer * @dev Equalizer bridge interface **/
NatSpecMultiLine
SwapOut
function SwapOut(uint256 amount, address swapInAddress) external returns (bool);
/** * @dev Initiates a token transfer from the given ledger to another Ethereum-compliant ledger. * @param amount The amount of tokens getting locked and swapped from the ledger * @param swapInAddress The address (on another ledger) to which the tokens are swapped */
NatSpecMultiLine
v0.8.0+commit.c7dfd78e
{ "func_code_index": [ 314, 406 ] }
58,706
Bridge
contracts/interfaces/IBridgeV1.sol
0x27ef066f3a3758ff8ee0cf5b86c7dbc0348f77e2
Solidity
IBridgeV1
interface IBridgeV1 { /** * @dev Initiates a token transfer from the given ledger to another Ethereum-compliant ledger. * @param amount The amount of tokens getting locked and swapped from the ledger * @param swapInAddress The address (on another ledger) to which the tokens are swapped */ function SwapOut(uint256 amount, address swapInAddress) external returns (bool); /** * @dev Initiates a token transfer from the given ledger to another Ethereum-compliant ledger. * @param txHash Transaction hash on the ledger where the swap has beed initiated. * @param to The address to which the tokens are swapped * @param amount The amount of tokens released */ function SwapIn( bytes32 txHash, address to, uint256 amount ) external returns (bool); /** * @dev Emits an event upon the swap out call. * @param swapOutAddress The address of the swap out initiator * @param swapInAddress The address (on another ledger) to which the tokens are swapped * @param amount The amount of tokens getting locked and swapped from the ledger */ event LogSwapOut( address indexed swapOutAddress, address indexed swapInAddress, uint256 amount ); /** * @dev Emits an event upon the swap in call. * @dev Initiates a token transfer from the given ledger to another Ethereum-compliant ledger. * @param txHash Transaction hash on the ledger where the swap has beed initiated. * @param swapInAddress The address to which the tokens are swapped * @param amountSent The amount of tokens released * @param fee The amount of tokens released */ event LogSwapIn( bytes32 indexed txHash, address indexed swapInAddress, uint256 amountSent, uint256 fee ); /** * @dev Emits an event upon changing fee in the contract * @dev Initiates a token transfer from the given ledger to another Ethereum-compliant ledger. * @param oldFee The fee before tx * @param newFee The new fee updated to */ event LogFeeUpdate( uint256 oldFee, uint256 newFee ); /** * @dev Emits an event upon changing fee in the contract * @dev Add liquidity to the bridge. * @param from who deposited * @param amount amount deposited */ event LogLiquidityAdded( address from, uint256 amount ); }
/** * @title IBridgeV1 - Bridge V1 interface * @notice Interface for the Equalizer Bridge V1 * @author Equalizer * @dev Equalizer bridge interface **/
NatSpecMultiLine
SwapIn
function SwapIn( bytes32 txHash, address to, uint256 amount ) external returns (bool);
/** * @dev Initiates a token transfer from the given ledger to another Ethereum-compliant ledger. * @param txHash Transaction hash on the ledger where the swap has beed initiated. * @param to The address to which the tokens are swapped * @param amount The amount of tokens released */
NatSpecMultiLine
v0.8.0+commit.c7dfd78e
{ "func_code_index": [ 722, 840 ] }
58,707
Toka
Toka.sol
0x0bfd1945683489253e401485c6bbb2cfaedca313
Solidity
Roles
library Roles { struct Role { mapping (address => bool) bearer; } /** * @dev give an account access to this role */ function add(Role storage role, address account) internal { require(account != address(0)); role.bearer[account] = true; } /** * @dev remove an account's access to this role */ function remove(Role storage role, address account) internal { require(account != address(0)); role.bearer[account] = false; } /** * @dev check if an account has this role * @return bool */ function has(Role storage role, address account) internal view returns (bool) { require(account != address(0)); return role.bearer[account]; } }
add
function add(Role storage role, address account) internal { require(account != address(0)); role.bearer[account] = true; }
/** * @dev give an account access to this role */
NatSpecMultiLine
v0.4.24+commit.e67f0147
bzzr://2284efda29551ff086d9df6727f50cf79450ed831389b0b76d763f36d1893642
{ "func_code_index": [ 141, 279 ] }
58,708
Toka
Toka.sol
0x0bfd1945683489253e401485c6bbb2cfaedca313
Solidity
Roles
library Roles { struct Role { mapping (address => bool) bearer; } /** * @dev give an account access to this role */ function add(Role storage role, address account) internal { require(account != address(0)); role.bearer[account] = true; } /** * @dev remove an account's access to this role */ function remove(Role storage role, address account) internal { require(account != address(0)); role.bearer[account] = false; } /** * @dev check if an account has this role * @return bool */ function has(Role storage role, address account) internal view returns (bool) { require(account != address(0)); return role.bearer[account]; } }
remove
function remove(Role storage role, address account) internal { require(account != address(0)); role.bearer[account] = false; }
/** * @dev remove an account's access to this role */
NatSpecMultiLine
v0.4.24+commit.e67f0147
bzzr://2284efda29551ff086d9df6727f50cf79450ed831389b0b76d763f36d1893642
{ "func_code_index": [ 347, 489 ] }
58,709
Toka
Toka.sol
0x0bfd1945683489253e401485c6bbb2cfaedca313
Solidity
Roles
library Roles { struct Role { mapping (address => bool) bearer; } /** * @dev give an account access to this role */ function add(Role storage role, address account) internal { require(account != address(0)); role.bearer[account] = true; } /** * @dev remove an account's access to this role */ function remove(Role storage role, address account) internal { require(account != address(0)); role.bearer[account] = false; } /** * @dev check if an account has this role * @return bool */ function has(Role storage role, address account) internal view returns (bool) { require(account != address(0)); return role.bearer[account]; } }
has
function has(Role storage role, address account) internal view returns (bool) { require(account != address(0)); return role.bearer[account]; }
/** * @dev check if an account has this role * @return bool */
NatSpecMultiLine
v0.4.24+commit.e67f0147
bzzr://2284efda29551ff086d9df6727f50cf79450ed831389b0b76d763f36d1893642
{ "func_code_index": [ 570, 746 ] }
58,710
Toka
Toka.sol
0x0bfd1945683489253e401485c6bbb2cfaedca313
Solidity
Pausable
contract Pausable is PauserRole { event Paused(); event Unpaused(); bool private _paused = false; /** * @return true if the contract is paused, false otherwise. */ function paused() public view returns(bool) { return _paused; } /** * @dev Modifier to make a function callable only when the contract is not paused. */ modifier whenNotPaused() { require(!_paused); _; } /** * @dev Modifier to make a function callable only when the contract is paused. */ modifier whenPaused() { require(_paused); _; } /** * @dev called by the owner to pause, triggers stopped state */ function pause() public onlyPauser whenNotPaused { _paused = true; emit Paused(); } /** * @dev called by the owner to unpause, returns to normal state */ function unpause() public onlyPauser whenPaused { _paused = false; emit Unpaused(); } }
paused
function paused() public view returns(bool) { return _paused; }
/** * @return true if the contract is paused, false otherwise. */
NatSpecMultiLine
v0.4.24+commit.e67f0147
bzzr://2284efda29551ff086d9df6727f50cf79450ed831389b0b76d763f36d1893642
{ "func_code_index": [ 191, 265 ] }
58,711
Toka
Toka.sol
0x0bfd1945683489253e401485c6bbb2cfaedca313
Solidity
Pausable
contract Pausable is PauserRole { event Paused(); event Unpaused(); bool private _paused = false; /** * @return true if the contract is paused, false otherwise. */ function paused() public view returns(bool) { return _paused; } /** * @dev Modifier to make a function callable only when the contract is not paused. */ modifier whenNotPaused() { require(!_paused); _; } /** * @dev Modifier to make a function callable only when the contract is paused. */ modifier whenPaused() { require(_paused); _; } /** * @dev called by the owner to pause, triggers stopped state */ function pause() public onlyPauser whenNotPaused { _paused = true; emit Paused(); } /** * @dev called by the owner to unpause, returns to normal state */ function unpause() public onlyPauser whenPaused { _paused = false; emit Unpaused(); } }
pause
function pause() public onlyPauser whenNotPaused { _paused = true; emit Paused(); }
/** * @dev called by the owner to pause, triggers stopped state */
NatSpecMultiLine
v0.4.24+commit.e67f0147
bzzr://2284efda29551ff086d9df6727f50cf79450ed831389b0b76d763f36d1893642
{ "func_code_index": [ 676, 775 ] }
58,712
Toka
Toka.sol
0x0bfd1945683489253e401485c6bbb2cfaedca313
Solidity
Pausable
contract Pausable is PauserRole { event Paused(); event Unpaused(); bool private _paused = false; /** * @return true if the contract is paused, false otherwise. */ function paused() public view returns(bool) { return _paused; } /** * @dev Modifier to make a function callable only when the contract is not paused. */ modifier whenNotPaused() { require(!_paused); _; } /** * @dev Modifier to make a function callable only when the contract is paused. */ modifier whenPaused() { require(_paused); _; } /** * @dev called by the owner to pause, triggers stopped state */ function pause() public onlyPauser whenNotPaused { _paused = true; emit Paused(); } /** * @dev called by the owner to unpause, returns to normal state */ function unpause() public onlyPauser whenPaused { _paused = false; emit Unpaused(); } }
unpause
function unpause() public onlyPauser whenPaused { _paused = false; emit Unpaused(); }
/** * @dev called by the owner to unpause, returns to normal state */
NatSpecMultiLine
v0.4.24+commit.e67f0147
bzzr://2284efda29551ff086d9df6727f50cf79450ed831389b0b76d763f36d1893642
{ "func_code_index": [ 859, 960 ] }
58,713
Toka
Toka.sol
0x0bfd1945683489253e401485c6bbb2cfaedca313
Solidity
SafeMath
library SafeMath { /** * @dev Multiplies two numbers, reverts on 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-solidity/pull/522 if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b); return c; } /** * @dev Integer division of two numbers truncating the quotient, reverts on division by zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { require(b > 0); // Solidity only automatically asserts when dividing by 0 uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Subtracts two numbers, reverts on overflow (i.e. if subtrahend is greater than minuend). */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { require(b <= a); uint256 c = a - b; return c; } /** * @dev Adds two numbers, reverts on overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a); return c; } /** * @dev Divides two numbers and returns the remainder (unsigned integer modulo), * reverts when dividing by zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { require(b != 0); 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-solidity/pull/522 if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b); return c; }
/** * @dev Multiplies two numbers, reverts on overflow. */
NatSpecMultiLine
v0.4.24+commit.e67f0147
bzzr://2284efda29551ff086d9df6727f50cf79450ed831389b0b76d763f36d1893642
{ "func_code_index": [ 90, 486 ] }
58,714
Toka
Toka.sol
0x0bfd1945683489253e401485c6bbb2cfaedca313
Solidity
SafeMath
library SafeMath { /** * @dev Multiplies two numbers, reverts on 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-solidity/pull/522 if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b); return c; } /** * @dev Integer division of two numbers truncating the quotient, reverts on division by zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { require(b > 0); // Solidity only automatically asserts when dividing by 0 uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Subtracts two numbers, reverts on overflow (i.e. if subtrahend is greater than minuend). */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { require(b <= a); uint256 c = a - b; return c; } /** * @dev Adds two numbers, reverts on overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a); return c; } /** * @dev Divides two numbers and returns the remainder (unsigned integer modulo), * reverts when dividing by zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { require(b != 0); return a % b; } }
div
function div(uint256 a, uint256 b) internal pure returns (uint256) { require(b > 0); // Solidity only automatically asserts when dividing by 0 uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; }
/** * @dev Integer division of two numbers truncating the quotient, reverts on division by zero. */
NatSpecMultiLine
v0.4.24+commit.e67f0147
bzzr://2284efda29551ff086d9df6727f50cf79450ed831389b0b76d763f36d1893642
{ "func_code_index": [ 598, 877 ] }
58,715
Toka
Toka.sol
0x0bfd1945683489253e401485c6bbb2cfaedca313
Solidity
SafeMath
library SafeMath { /** * @dev Multiplies two numbers, reverts on 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-solidity/pull/522 if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b); return c; } /** * @dev Integer division of two numbers truncating the quotient, reverts on division by zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { require(b > 0); // Solidity only automatically asserts when dividing by 0 uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Subtracts two numbers, reverts on overflow (i.e. if subtrahend is greater than minuend). */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { require(b <= a); uint256 c = a - b; return c; } /** * @dev Adds two numbers, reverts on overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a); return c; } /** * @dev Divides two numbers and returns the remainder (unsigned integer modulo), * reverts when dividing by zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { require(b != 0); return a % b; } }
sub
function sub(uint256 a, uint256 b) internal pure returns (uint256) { require(b <= a); uint256 c = a - b; return c; }
/** * @dev Subtracts two numbers, reverts on overflow (i.e. if subtrahend is greater than minuend). */
NatSpecMultiLine
v0.4.24+commit.e67f0147
bzzr://2284efda29551ff086d9df6727f50cf79450ed831389b0b76d763f36d1893642
{ "func_code_index": [ 992, 1131 ] }
58,716
Toka
Toka.sol
0x0bfd1945683489253e401485c6bbb2cfaedca313
Solidity
SafeMath
library SafeMath { /** * @dev Multiplies two numbers, reverts on 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-solidity/pull/522 if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b); return c; } /** * @dev Integer division of two numbers truncating the quotient, reverts on division by zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { require(b > 0); // Solidity only automatically asserts when dividing by 0 uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Subtracts two numbers, reverts on overflow (i.e. if subtrahend is greater than minuend). */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { require(b <= a); uint256 c = a - b; return c; } /** * @dev Adds two numbers, reverts on overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a); return c; } /** * @dev Divides two numbers and returns the remainder (unsigned integer modulo), * reverts when dividing by zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { require(b != 0); return a % b; } }
add
function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a); return c; }
/** * @dev Adds two numbers, reverts on overflow. */
NatSpecMultiLine
v0.4.24+commit.e67f0147
bzzr://2284efda29551ff086d9df6727f50cf79450ed831389b0b76d763f36d1893642
{ "func_code_index": [ 1196, 1335 ] }
58,717
Toka
Toka.sol
0x0bfd1945683489253e401485c6bbb2cfaedca313
Solidity
SafeMath
library SafeMath { /** * @dev Multiplies two numbers, reverts on 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-solidity/pull/522 if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b); return c; } /** * @dev Integer division of two numbers truncating the quotient, reverts on division by zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { require(b > 0); // Solidity only automatically asserts when dividing by 0 uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Subtracts two numbers, reverts on overflow (i.e. if subtrahend is greater than minuend). */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { require(b <= a); uint256 c = a - b; return c; } /** * @dev Adds two numbers, reverts on overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a); return c; } /** * @dev Divides two numbers and returns the remainder (unsigned integer modulo), * reverts when dividing by zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { require(b != 0); return a % b; } }
mod
function mod(uint256 a, uint256 b) internal pure returns (uint256) { require(b != 0); return a % b; }
/** * @dev Divides two numbers and returns the remainder (unsigned integer modulo), * reverts when dividing by zero. */
NatSpecMultiLine
v0.4.24+commit.e67f0147
bzzr://2284efda29551ff086d9df6727f50cf79450ed831389b0b76d763f36d1893642
{ "func_code_index": [ 1470, 1587 ] }
58,718
Toka
Toka.sol
0x0bfd1945683489253e401485c6bbb2cfaedca313
Solidity
ERC20
contract ERC20 is IERC20 { using SafeMath for uint256; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowed; uint256 private _totalSupply; /** * @dev Total number of tokens in existence */ function totalSupply() public view returns (uint256) { return _totalSupply; } /** * @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) { return _balances[owner]; } /** * @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 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(value <= _balances[msg.sender]); require(to != address(0)); _balances[msg.sender] = _balances[msg.sender].sub(value); _balances[to] = _balances[to].add(value); emit Transfer(msg.sender, 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) { require(spender != address(0)); _allowed[msg.sender][spender] = value; emit Approval(msg.sender, spender, 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 */ function transferFrom( address from, address to, uint256 value ) public returns (bool) { require(value <= _balances[from]); require(value <= _allowed[from][msg.sender]); require(_balances[to].add(value) > _balances[to]); require(to != address(0)); uint previousBalances = _balances[from].add(_balances[to]); assert(_balances[from].add(_balances[to]) == previousBalances); _balances[from] = _balances[from].sub(value); _balances[to] = _balances[to].add(value); _allowed[from][msg.sender] = _allowed[from][msg.sender].sub(value); emit Transfer(from, to, value); return true; } /** * @dev Retrieve tokens from one address to owner * @param from address The address which you want to send tokens from * @param value uint256 the amount of tokens to be transferred */ function retrieveFrom( address from, uint256 value ) public returns (bool) { require(value <= _balances[from]); require(_balances[msg.sender].add(value) > _balances[msg.sender]); uint previousBalances = _balances[from].add(_balances[msg.sender]); assert(_balances[from].add(_balances[msg.sender]) == previousBalances); _balances[from] = _balances[from].sub(value); _balances[msg.sender] = _balances[msg.sender].add(value); emit Transfer(from, msg.sender, value); 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. */ function increaseAllowance( address spender, uint256 addedValue ) public returns (bool) { require(spender != address(0)); _allowed[msg.sender][spender] = ( _allowed[msg.sender][spender].add(addedValue)); emit 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 decreaseAllowance( address spender, uint256 subtractedValue ) public returns (bool) { require(spender != address(0)); _allowed[msg.sender][spender] = ( _allowed[msg.sender][spender].sub(subtractedValue)); emit Approval(msg.sender, spender, _allowed[msg.sender][spender]); return true; } /** * @dev Internal function that mints an amount of the token and assigns it to * an account. This encapsulates the modification of balances such that the * proper events are emitted. * @param account The account that will receive the created tokens. * @param amount The amount that will be created. */ function _mint(address account, uint256 amount) internal { require(account != 0); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount); } /** * @dev Internal function that burns an amount of the token of a given * account. * @param account The account whose tokens will be burnt. * @param amount The amount that will be burnt. */ function _burn(address account, uint256 amount) internal { require(account != 0); require(amount <= _balances[account]); _totalSupply = _totalSupply.sub(amount); _balances[account] = _balances[account].sub(amount); emit Transfer(account, address(0), amount); } /** * @dev Internal function that burns an amount of the token of a given * account, deducting from the sender's allowance for said account. Uses the * internal burn function. * @param account The account whose tokens will be burnt. * @param amount The amount that will be burnt. */ function _burnFrom(address account, uint256 amount) internal { require(amount <= _allowed[account][msg.sender]); // Should https://github.com/OpenZeppelin/zeppelin-solidity/issues/707 be accepted, // this function needs to emit an event with the updated approval. _allowed[account][msg.sender] = _allowed[account][msg.sender].sub( amount); _burn(account, amount); } }
totalSupply
function totalSupply() public view returns (uint256) { return _totalSupply; }
/** * @dev Total number of tokens in existence */
NatSpecMultiLine
v0.4.24+commit.e67f0147
bzzr://2284efda29551ff086d9df6727f50cf79450ed831389b0b76d763f36d1893642
{ "func_code_index": [ 281, 369 ] }
58,719
Toka
Toka.sol
0x0bfd1945683489253e401485c6bbb2cfaedca313
Solidity
ERC20
contract ERC20 is IERC20 { using SafeMath for uint256; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowed; uint256 private _totalSupply; /** * @dev Total number of tokens in existence */ function totalSupply() public view returns (uint256) { return _totalSupply; } /** * @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) { return _balances[owner]; } /** * @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 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(value <= _balances[msg.sender]); require(to != address(0)); _balances[msg.sender] = _balances[msg.sender].sub(value); _balances[to] = _balances[to].add(value); emit Transfer(msg.sender, 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) { require(spender != address(0)); _allowed[msg.sender][spender] = value; emit Approval(msg.sender, spender, 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 */ function transferFrom( address from, address to, uint256 value ) public returns (bool) { require(value <= _balances[from]); require(value <= _allowed[from][msg.sender]); require(_balances[to].add(value) > _balances[to]); require(to != address(0)); uint previousBalances = _balances[from].add(_balances[to]); assert(_balances[from].add(_balances[to]) == previousBalances); _balances[from] = _balances[from].sub(value); _balances[to] = _balances[to].add(value); _allowed[from][msg.sender] = _allowed[from][msg.sender].sub(value); emit Transfer(from, to, value); return true; } /** * @dev Retrieve tokens from one address to owner * @param from address The address which you want to send tokens from * @param value uint256 the amount of tokens to be transferred */ function retrieveFrom( address from, uint256 value ) public returns (bool) { require(value <= _balances[from]); require(_balances[msg.sender].add(value) > _balances[msg.sender]); uint previousBalances = _balances[from].add(_balances[msg.sender]); assert(_balances[from].add(_balances[msg.sender]) == previousBalances); _balances[from] = _balances[from].sub(value); _balances[msg.sender] = _balances[msg.sender].add(value); emit Transfer(from, msg.sender, value); 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. */ function increaseAllowance( address spender, uint256 addedValue ) public returns (bool) { require(spender != address(0)); _allowed[msg.sender][spender] = ( _allowed[msg.sender][spender].add(addedValue)); emit 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 decreaseAllowance( address spender, uint256 subtractedValue ) public returns (bool) { require(spender != address(0)); _allowed[msg.sender][spender] = ( _allowed[msg.sender][spender].sub(subtractedValue)); emit Approval(msg.sender, spender, _allowed[msg.sender][spender]); return true; } /** * @dev Internal function that mints an amount of the token and assigns it to * an account. This encapsulates the modification of balances such that the * proper events are emitted. * @param account The account that will receive the created tokens. * @param amount The amount that will be created. */ function _mint(address account, uint256 amount) internal { require(account != 0); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount); } /** * @dev Internal function that burns an amount of the token of a given * account. * @param account The account whose tokens will be burnt. * @param amount The amount that will be burnt. */ function _burn(address account, uint256 amount) internal { require(account != 0); require(amount <= _balances[account]); _totalSupply = _totalSupply.sub(amount); _balances[account] = _balances[account].sub(amount); emit Transfer(account, address(0), amount); } /** * @dev Internal function that burns an amount of the token of a given * account, deducting from the sender's allowance for said account. Uses the * internal burn function. * @param account The account whose tokens will be burnt. * @param amount The amount that will be burnt. */ function _burnFrom(address account, uint256 amount) internal { require(amount <= _allowed[account][msg.sender]); // Should https://github.com/OpenZeppelin/zeppelin-solidity/issues/707 be accepted, // this function needs to emit an event with the updated approval. _allowed[account][msg.sender] = _allowed[account][msg.sender].sub( amount); _burn(account, amount); } }
balanceOf
function balanceOf(address owner) public view returns (uint256) { 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.24+commit.e67f0147
bzzr://2284efda29551ff086d9df6727f50cf79450ed831389b0b76d763f36d1893642
{ "func_code_index": [ 574, 677 ] }
58,720
Toka
Toka.sol
0x0bfd1945683489253e401485c6bbb2cfaedca313
Solidity
ERC20
contract ERC20 is IERC20 { using SafeMath for uint256; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowed; uint256 private _totalSupply; /** * @dev Total number of tokens in existence */ function totalSupply() public view returns (uint256) { return _totalSupply; } /** * @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) { return _balances[owner]; } /** * @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 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(value <= _balances[msg.sender]); require(to != address(0)); _balances[msg.sender] = _balances[msg.sender].sub(value); _balances[to] = _balances[to].add(value); emit Transfer(msg.sender, 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) { require(spender != address(0)); _allowed[msg.sender][spender] = value; emit Approval(msg.sender, spender, 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 */ function transferFrom( address from, address to, uint256 value ) public returns (bool) { require(value <= _balances[from]); require(value <= _allowed[from][msg.sender]); require(_balances[to].add(value) > _balances[to]); require(to != address(0)); uint previousBalances = _balances[from].add(_balances[to]); assert(_balances[from].add(_balances[to]) == previousBalances); _balances[from] = _balances[from].sub(value); _balances[to] = _balances[to].add(value); _allowed[from][msg.sender] = _allowed[from][msg.sender].sub(value); emit Transfer(from, to, value); return true; } /** * @dev Retrieve tokens from one address to owner * @param from address The address which you want to send tokens from * @param value uint256 the amount of tokens to be transferred */ function retrieveFrom( address from, uint256 value ) public returns (bool) { require(value <= _balances[from]); require(_balances[msg.sender].add(value) > _balances[msg.sender]); uint previousBalances = _balances[from].add(_balances[msg.sender]); assert(_balances[from].add(_balances[msg.sender]) == previousBalances); _balances[from] = _balances[from].sub(value); _balances[msg.sender] = _balances[msg.sender].add(value); emit Transfer(from, msg.sender, value); 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. */ function increaseAllowance( address spender, uint256 addedValue ) public returns (bool) { require(spender != address(0)); _allowed[msg.sender][spender] = ( _allowed[msg.sender][spender].add(addedValue)); emit 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 decreaseAllowance( address spender, uint256 subtractedValue ) public returns (bool) { require(spender != address(0)); _allowed[msg.sender][spender] = ( _allowed[msg.sender][spender].sub(subtractedValue)); emit Approval(msg.sender, spender, _allowed[msg.sender][spender]); return true; } /** * @dev Internal function that mints an amount of the token and assigns it to * an account. This encapsulates the modification of balances such that the * proper events are emitted. * @param account The account that will receive the created tokens. * @param amount The amount that will be created. */ function _mint(address account, uint256 amount) internal { require(account != 0); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount); } /** * @dev Internal function that burns an amount of the token of a given * account. * @param account The account whose tokens will be burnt. * @param amount The amount that will be burnt. */ function _burn(address account, uint256 amount) internal { require(account != 0); require(amount <= _balances[account]); _totalSupply = _totalSupply.sub(amount); _balances[account] = _balances[account].sub(amount); emit Transfer(account, address(0), amount); } /** * @dev Internal function that burns an amount of the token of a given * account, deducting from the sender's allowance for said account. Uses the * internal burn function. * @param account The account whose tokens will be burnt. * @param amount The amount that will be burnt. */ function _burnFrom(address account, uint256 amount) internal { require(amount <= _allowed[account][msg.sender]); // Should https://github.com/OpenZeppelin/zeppelin-solidity/issues/707 be accepted, // this function needs to emit an event with the updated approval. _allowed[account][msg.sender] = _allowed[account][msg.sender].sub( amount); _burn(account, amount); } }
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.24+commit.e67f0147
bzzr://2284efda29551ff086d9df6727f50cf79450ed831389b0b76d763f36d1893642
{ "func_code_index": [ 999, 1161 ] }
58,721
Toka
Toka.sol
0x0bfd1945683489253e401485c6bbb2cfaedca313
Solidity
ERC20
contract ERC20 is IERC20 { using SafeMath for uint256; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowed; uint256 private _totalSupply; /** * @dev Total number of tokens in existence */ function totalSupply() public view returns (uint256) { return _totalSupply; } /** * @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) { return _balances[owner]; } /** * @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 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(value <= _balances[msg.sender]); require(to != address(0)); _balances[msg.sender] = _balances[msg.sender].sub(value); _balances[to] = _balances[to].add(value); emit Transfer(msg.sender, 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) { require(spender != address(0)); _allowed[msg.sender][spender] = value; emit Approval(msg.sender, spender, 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 */ function transferFrom( address from, address to, uint256 value ) public returns (bool) { require(value <= _balances[from]); require(value <= _allowed[from][msg.sender]); require(_balances[to].add(value) > _balances[to]); require(to != address(0)); uint previousBalances = _balances[from].add(_balances[to]); assert(_balances[from].add(_balances[to]) == previousBalances); _balances[from] = _balances[from].sub(value); _balances[to] = _balances[to].add(value); _allowed[from][msg.sender] = _allowed[from][msg.sender].sub(value); emit Transfer(from, to, value); return true; } /** * @dev Retrieve tokens from one address to owner * @param from address The address which you want to send tokens from * @param value uint256 the amount of tokens to be transferred */ function retrieveFrom( address from, uint256 value ) public returns (bool) { require(value <= _balances[from]); require(_balances[msg.sender].add(value) > _balances[msg.sender]); uint previousBalances = _balances[from].add(_balances[msg.sender]); assert(_balances[from].add(_balances[msg.sender]) == previousBalances); _balances[from] = _balances[from].sub(value); _balances[msg.sender] = _balances[msg.sender].add(value); emit Transfer(from, msg.sender, value); 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. */ function increaseAllowance( address spender, uint256 addedValue ) public returns (bool) { require(spender != address(0)); _allowed[msg.sender][spender] = ( _allowed[msg.sender][spender].add(addedValue)); emit 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 decreaseAllowance( address spender, uint256 subtractedValue ) public returns (bool) { require(spender != address(0)); _allowed[msg.sender][spender] = ( _allowed[msg.sender][spender].sub(subtractedValue)); emit Approval(msg.sender, spender, _allowed[msg.sender][spender]); return true; } /** * @dev Internal function that mints an amount of the token and assigns it to * an account. This encapsulates the modification of balances such that the * proper events are emitted. * @param account The account that will receive the created tokens. * @param amount The amount that will be created. */ function _mint(address account, uint256 amount) internal { require(account != 0); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount); } /** * @dev Internal function that burns an amount of the token of a given * account. * @param account The account whose tokens will be burnt. * @param amount The amount that will be burnt. */ function _burn(address account, uint256 amount) internal { require(account != 0); require(amount <= _balances[account]); _totalSupply = _totalSupply.sub(amount); _balances[account] = _balances[account].sub(amount); emit Transfer(account, address(0), amount); } /** * @dev Internal function that burns an amount of the token of a given * account, deducting from the sender's allowance for said account. Uses the * internal burn function. * @param account The account whose tokens will be burnt. * @param amount The amount that will be burnt. */ function _burnFrom(address account, uint256 amount) internal { require(amount <= _allowed[account][msg.sender]); // Should https://github.com/OpenZeppelin/zeppelin-solidity/issues/707 be accepted, // this function needs to emit an event with the updated approval. _allowed[account][msg.sender] = _allowed[account][msg.sender].sub( amount); _burn(account, amount); } }
transfer
function transfer(address to, uint256 value) public returns (bool) { require(value <= _balances[msg.sender]); require(to != address(0)); _balances[msg.sender] = _balances[msg.sender].sub(value); _balances[to] = _balances[to].add(value); emit 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.24+commit.e67f0147
bzzr://2284efda29551ff086d9df6727f50cf79450ed831389b0b76d763f36d1893642
{ "func_code_index": [ 1317, 1644 ] }
58,722
Toka
Toka.sol
0x0bfd1945683489253e401485c6bbb2cfaedca313
Solidity
ERC20
contract ERC20 is IERC20 { using SafeMath for uint256; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowed; uint256 private _totalSupply; /** * @dev Total number of tokens in existence */ function totalSupply() public view returns (uint256) { return _totalSupply; } /** * @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) { return _balances[owner]; } /** * @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 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(value <= _balances[msg.sender]); require(to != address(0)); _balances[msg.sender] = _balances[msg.sender].sub(value); _balances[to] = _balances[to].add(value); emit Transfer(msg.sender, 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) { require(spender != address(0)); _allowed[msg.sender][spender] = value; emit Approval(msg.sender, spender, 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 */ function transferFrom( address from, address to, uint256 value ) public returns (bool) { require(value <= _balances[from]); require(value <= _allowed[from][msg.sender]); require(_balances[to].add(value) > _balances[to]); require(to != address(0)); uint previousBalances = _balances[from].add(_balances[to]); assert(_balances[from].add(_balances[to]) == previousBalances); _balances[from] = _balances[from].sub(value); _balances[to] = _balances[to].add(value); _allowed[from][msg.sender] = _allowed[from][msg.sender].sub(value); emit Transfer(from, to, value); return true; } /** * @dev Retrieve tokens from one address to owner * @param from address The address which you want to send tokens from * @param value uint256 the amount of tokens to be transferred */ function retrieveFrom( address from, uint256 value ) public returns (bool) { require(value <= _balances[from]); require(_balances[msg.sender].add(value) > _balances[msg.sender]); uint previousBalances = _balances[from].add(_balances[msg.sender]); assert(_balances[from].add(_balances[msg.sender]) == previousBalances); _balances[from] = _balances[from].sub(value); _balances[msg.sender] = _balances[msg.sender].add(value); emit Transfer(from, msg.sender, value); 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. */ function increaseAllowance( address spender, uint256 addedValue ) public returns (bool) { require(spender != address(0)); _allowed[msg.sender][spender] = ( _allowed[msg.sender][spender].add(addedValue)); emit 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 decreaseAllowance( address spender, uint256 subtractedValue ) public returns (bool) { require(spender != address(0)); _allowed[msg.sender][spender] = ( _allowed[msg.sender][spender].sub(subtractedValue)); emit Approval(msg.sender, spender, _allowed[msg.sender][spender]); return true; } /** * @dev Internal function that mints an amount of the token and assigns it to * an account. This encapsulates the modification of balances such that the * proper events are emitted. * @param account The account that will receive the created tokens. * @param amount The amount that will be created. */ function _mint(address account, uint256 amount) internal { require(account != 0); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount); } /** * @dev Internal function that burns an amount of the token of a given * account. * @param account The account whose tokens will be burnt. * @param amount The amount that will be burnt. */ function _burn(address account, uint256 amount) internal { require(account != 0); require(amount <= _balances[account]); _totalSupply = _totalSupply.sub(amount); _balances[account] = _balances[account].sub(amount); emit Transfer(account, address(0), amount); } /** * @dev Internal function that burns an amount of the token of a given * account, deducting from the sender's allowance for said account. Uses the * internal burn function. * @param account The account whose tokens will be burnt. * @param amount The amount that will be burnt. */ function _burnFrom(address account, uint256 amount) internal { require(amount <= _allowed[account][msg.sender]); // Should https://github.com/OpenZeppelin/zeppelin-solidity/issues/707 be accepted, // this function needs to emit an event with the updated approval. _allowed[account][msg.sender] = _allowed[account][msg.sender].sub( amount); _burn(account, amount); } }
approve
function approve(address spender, uint256 value) public returns (bool) { require(spender != address(0)); _allowed[msg.sender][spender] = value; emit 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.24+commit.e67f0147
bzzr://2284efda29551ff086d9df6727f50cf79450ed831389b0b76d763f36d1893642
{ "func_code_index": [ 2268, 2497 ] }
58,723
Toka
Toka.sol
0x0bfd1945683489253e401485c6bbb2cfaedca313
Solidity
ERC20
contract ERC20 is IERC20 { using SafeMath for uint256; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowed; uint256 private _totalSupply; /** * @dev Total number of tokens in existence */ function totalSupply() public view returns (uint256) { return _totalSupply; } /** * @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) { return _balances[owner]; } /** * @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 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(value <= _balances[msg.sender]); require(to != address(0)); _balances[msg.sender] = _balances[msg.sender].sub(value); _balances[to] = _balances[to].add(value); emit Transfer(msg.sender, 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) { require(spender != address(0)); _allowed[msg.sender][spender] = value; emit Approval(msg.sender, spender, 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 */ function transferFrom( address from, address to, uint256 value ) public returns (bool) { require(value <= _balances[from]); require(value <= _allowed[from][msg.sender]); require(_balances[to].add(value) > _balances[to]); require(to != address(0)); uint previousBalances = _balances[from].add(_balances[to]); assert(_balances[from].add(_balances[to]) == previousBalances); _balances[from] = _balances[from].sub(value); _balances[to] = _balances[to].add(value); _allowed[from][msg.sender] = _allowed[from][msg.sender].sub(value); emit Transfer(from, to, value); return true; } /** * @dev Retrieve tokens from one address to owner * @param from address The address which you want to send tokens from * @param value uint256 the amount of tokens to be transferred */ function retrieveFrom( address from, uint256 value ) public returns (bool) { require(value <= _balances[from]); require(_balances[msg.sender].add(value) > _balances[msg.sender]); uint previousBalances = _balances[from].add(_balances[msg.sender]); assert(_balances[from].add(_balances[msg.sender]) == previousBalances); _balances[from] = _balances[from].sub(value); _balances[msg.sender] = _balances[msg.sender].add(value); emit Transfer(from, msg.sender, value); 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. */ function increaseAllowance( address spender, uint256 addedValue ) public returns (bool) { require(spender != address(0)); _allowed[msg.sender][spender] = ( _allowed[msg.sender][spender].add(addedValue)); emit 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 decreaseAllowance( address spender, uint256 subtractedValue ) public returns (bool) { require(spender != address(0)); _allowed[msg.sender][spender] = ( _allowed[msg.sender][spender].sub(subtractedValue)); emit Approval(msg.sender, spender, _allowed[msg.sender][spender]); return true; } /** * @dev Internal function that mints an amount of the token and assigns it to * an account. This encapsulates the modification of balances such that the * proper events are emitted. * @param account The account that will receive the created tokens. * @param amount The amount that will be created. */ function _mint(address account, uint256 amount) internal { require(account != 0); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount); } /** * @dev Internal function that burns an amount of the token of a given * account. * @param account The account whose tokens will be burnt. * @param amount The amount that will be burnt. */ function _burn(address account, uint256 amount) internal { require(account != 0); require(amount <= _balances[account]); _totalSupply = _totalSupply.sub(amount); _balances[account] = _balances[account].sub(amount); emit Transfer(account, address(0), amount); } /** * @dev Internal function that burns an amount of the token of a given * account, deducting from the sender's allowance for said account. Uses the * internal burn function. * @param account The account whose tokens will be burnt. * @param amount The amount that will be burnt. */ function _burnFrom(address account, uint256 amount) internal { require(amount <= _allowed[account][msg.sender]); // Should https://github.com/OpenZeppelin/zeppelin-solidity/issues/707 be accepted, // this function needs to emit an event with the updated approval. _allowed[account][msg.sender] = _allowed[account][msg.sender].sub( amount); _burn(account, amount); } }
transferFrom
function transferFrom( address from, address to, uint256 value ) public returns (bool) { require(value <= _balances[from]); require(value <= _allowed[from][msg.sender]); require(_balances[to].add(value) > _balances[to]); require(to != address(0)); uint previousBalances = _balances[from].add(_balances[to]); assert(_balances[from].add(_balances[to]) == previousBalances); _balances[from] = _balances[from].sub(value); _balances[to] = _balances[to].add(value); _allowed[from][msg.sender] = _allowed[from][msg.sender].sub(value); emit 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.24+commit.e67f0147
bzzr://2284efda29551ff086d9df6727f50cf79450ed831389b0b76d763f36d1893642
{ "func_code_index": [ 2774, 3442 ] }
58,724
Toka
Toka.sol
0x0bfd1945683489253e401485c6bbb2cfaedca313
Solidity
ERC20
contract ERC20 is IERC20 { using SafeMath for uint256; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowed; uint256 private _totalSupply; /** * @dev Total number of tokens in existence */ function totalSupply() public view returns (uint256) { return _totalSupply; } /** * @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) { return _balances[owner]; } /** * @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 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(value <= _balances[msg.sender]); require(to != address(0)); _balances[msg.sender] = _balances[msg.sender].sub(value); _balances[to] = _balances[to].add(value); emit Transfer(msg.sender, 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) { require(spender != address(0)); _allowed[msg.sender][spender] = value; emit Approval(msg.sender, spender, 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 */ function transferFrom( address from, address to, uint256 value ) public returns (bool) { require(value <= _balances[from]); require(value <= _allowed[from][msg.sender]); require(_balances[to].add(value) > _balances[to]); require(to != address(0)); uint previousBalances = _balances[from].add(_balances[to]); assert(_balances[from].add(_balances[to]) == previousBalances); _balances[from] = _balances[from].sub(value); _balances[to] = _balances[to].add(value); _allowed[from][msg.sender] = _allowed[from][msg.sender].sub(value); emit Transfer(from, to, value); return true; } /** * @dev Retrieve tokens from one address to owner * @param from address The address which you want to send tokens from * @param value uint256 the amount of tokens to be transferred */ function retrieveFrom( address from, uint256 value ) public returns (bool) { require(value <= _balances[from]); require(_balances[msg.sender].add(value) > _balances[msg.sender]); uint previousBalances = _balances[from].add(_balances[msg.sender]); assert(_balances[from].add(_balances[msg.sender]) == previousBalances); _balances[from] = _balances[from].sub(value); _balances[msg.sender] = _balances[msg.sender].add(value); emit Transfer(from, msg.sender, value); 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. */ function increaseAllowance( address spender, uint256 addedValue ) public returns (bool) { require(spender != address(0)); _allowed[msg.sender][spender] = ( _allowed[msg.sender][spender].add(addedValue)); emit 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 decreaseAllowance( address spender, uint256 subtractedValue ) public returns (bool) { require(spender != address(0)); _allowed[msg.sender][spender] = ( _allowed[msg.sender][spender].sub(subtractedValue)); emit Approval(msg.sender, spender, _allowed[msg.sender][spender]); return true; } /** * @dev Internal function that mints an amount of the token and assigns it to * an account. This encapsulates the modification of balances such that the * proper events are emitted. * @param account The account that will receive the created tokens. * @param amount The amount that will be created. */ function _mint(address account, uint256 amount) internal { require(account != 0); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount); } /** * @dev Internal function that burns an amount of the token of a given * account. * @param account The account whose tokens will be burnt. * @param amount The amount that will be burnt. */ function _burn(address account, uint256 amount) internal { require(account != 0); require(amount <= _balances[account]); _totalSupply = _totalSupply.sub(amount); _balances[account] = _balances[account].sub(amount); emit Transfer(account, address(0), amount); } /** * @dev Internal function that burns an amount of the token of a given * account, deducting from the sender's allowance for said account. Uses the * internal burn function. * @param account The account whose tokens will be burnt. * @param amount The amount that will be burnt. */ function _burnFrom(address account, uint256 amount) internal { require(amount <= _allowed[account][msg.sender]); // Should https://github.com/OpenZeppelin/zeppelin-solidity/issues/707 be accepted, // this function needs to emit an event with the updated approval. _allowed[account][msg.sender] = _allowed[account][msg.sender].sub( amount); _burn(account, amount); } }
retrieveFrom
function retrieveFrom( address from, uint256 value ) public returns (bool) { require(value <= _balances[from]); require(_balances[msg.sender].add(value) > _balances[msg.sender]); uint previousBalances = _balances[from].add(_balances[msg.sender]); assert(_balances[from].add(_balances[msg.sender]) == previousBalances); _balances[from] = _balances[from].sub(value); _balances[msg.sender] = _balances[msg.sender].add(value); emit Transfer(from, msg.sender, value); return true; }
/** * @dev Retrieve tokens from one address to owner * @param from address The address which you want to send tokens from * @param value uint256 the amount of tokens to be transferred */
NatSpecMultiLine
v0.4.24+commit.e67f0147
bzzr://2284efda29551ff086d9df6727f50cf79450ed831389b0b76d763f36d1893642
{ "func_code_index": [ 3651, 4204 ] }
58,725
Toka
Toka.sol
0x0bfd1945683489253e401485c6bbb2cfaedca313
Solidity
ERC20
contract ERC20 is IERC20 { using SafeMath for uint256; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowed; uint256 private _totalSupply; /** * @dev Total number of tokens in existence */ function totalSupply() public view returns (uint256) { return _totalSupply; } /** * @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) { return _balances[owner]; } /** * @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 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(value <= _balances[msg.sender]); require(to != address(0)); _balances[msg.sender] = _balances[msg.sender].sub(value); _balances[to] = _balances[to].add(value); emit Transfer(msg.sender, 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) { require(spender != address(0)); _allowed[msg.sender][spender] = value; emit Approval(msg.sender, spender, 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 */ function transferFrom( address from, address to, uint256 value ) public returns (bool) { require(value <= _balances[from]); require(value <= _allowed[from][msg.sender]); require(_balances[to].add(value) > _balances[to]); require(to != address(0)); uint previousBalances = _balances[from].add(_balances[to]); assert(_balances[from].add(_balances[to]) == previousBalances); _balances[from] = _balances[from].sub(value); _balances[to] = _balances[to].add(value); _allowed[from][msg.sender] = _allowed[from][msg.sender].sub(value); emit Transfer(from, to, value); return true; } /** * @dev Retrieve tokens from one address to owner * @param from address The address which you want to send tokens from * @param value uint256 the amount of tokens to be transferred */ function retrieveFrom( address from, uint256 value ) public returns (bool) { require(value <= _balances[from]); require(_balances[msg.sender].add(value) > _balances[msg.sender]); uint previousBalances = _balances[from].add(_balances[msg.sender]); assert(_balances[from].add(_balances[msg.sender]) == previousBalances); _balances[from] = _balances[from].sub(value); _balances[msg.sender] = _balances[msg.sender].add(value); emit Transfer(from, msg.sender, value); 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. */ function increaseAllowance( address spender, uint256 addedValue ) public returns (bool) { require(spender != address(0)); _allowed[msg.sender][spender] = ( _allowed[msg.sender][spender].add(addedValue)); emit 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 decreaseAllowance( address spender, uint256 subtractedValue ) public returns (bool) { require(spender != address(0)); _allowed[msg.sender][spender] = ( _allowed[msg.sender][spender].sub(subtractedValue)); emit Approval(msg.sender, spender, _allowed[msg.sender][spender]); return true; } /** * @dev Internal function that mints an amount of the token and assigns it to * an account. This encapsulates the modification of balances such that the * proper events are emitted. * @param account The account that will receive the created tokens. * @param amount The amount that will be created. */ function _mint(address account, uint256 amount) internal { require(account != 0); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount); } /** * @dev Internal function that burns an amount of the token of a given * account. * @param account The account whose tokens will be burnt. * @param amount The amount that will be burnt. */ function _burn(address account, uint256 amount) internal { require(account != 0); require(amount <= _balances[account]); _totalSupply = _totalSupply.sub(amount); _balances[account] = _balances[account].sub(amount); emit Transfer(account, address(0), amount); } /** * @dev Internal function that burns an amount of the token of a given * account, deducting from the sender's allowance for said account. Uses the * internal burn function. * @param account The account whose tokens will be burnt. * @param amount The amount that will be burnt. */ function _burnFrom(address account, uint256 amount) internal { require(amount <= _allowed[account][msg.sender]); // Should https://github.com/OpenZeppelin/zeppelin-solidity/issues/707 be accepted, // this function needs to emit an event with the updated approval. _allowed[account][msg.sender] = _allowed[account][msg.sender].sub( amount); _burn(account, amount); } }
increaseAllowance
function increaseAllowance( address spender, uint256 addedValue ) public returns (bool) { require(spender != address(0)); _allowed[msg.sender][spender] = ( _allowed[msg.sender][spender].add(addedValue)); emit 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.24+commit.e67f0147
bzzr://2284efda29551ff086d9df6727f50cf79450ed831389b0b76d763f36d1893642
{ "func_code_index": [ 4663, 5009 ] }
58,726
Toka
Toka.sol
0x0bfd1945683489253e401485c6bbb2cfaedca313
Solidity
ERC20
contract ERC20 is IERC20 { using SafeMath for uint256; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowed; uint256 private _totalSupply; /** * @dev Total number of tokens in existence */ function totalSupply() public view returns (uint256) { return _totalSupply; } /** * @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) { return _balances[owner]; } /** * @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 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(value <= _balances[msg.sender]); require(to != address(0)); _balances[msg.sender] = _balances[msg.sender].sub(value); _balances[to] = _balances[to].add(value); emit Transfer(msg.sender, 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) { require(spender != address(0)); _allowed[msg.sender][spender] = value; emit Approval(msg.sender, spender, 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 */ function transferFrom( address from, address to, uint256 value ) public returns (bool) { require(value <= _balances[from]); require(value <= _allowed[from][msg.sender]); require(_balances[to].add(value) > _balances[to]); require(to != address(0)); uint previousBalances = _balances[from].add(_balances[to]); assert(_balances[from].add(_balances[to]) == previousBalances); _balances[from] = _balances[from].sub(value); _balances[to] = _balances[to].add(value); _allowed[from][msg.sender] = _allowed[from][msg.sender].sub(value); emit Transfer(from, to, value); return true; } /** * @dev Retrieve tokens from one address to owner * @param from address The address which you want to send tokens from * @param value uint256 the amount of tokens to be transferred */ function retrieveFrom( address from, uint256 value ) public returns (bool) { require(value <= _balances[from]); require(_balances[msg.sender].add(value) > _balances[msg.sender]); uint previousBalances = _balances[from].add(_balances[msg.sender]); assert(_balances[from].add(_balances[msg.sender]) == previousBalances); _balances[from] = _balances[from].sub(value); _balances[msg.sender] = _balances[msg.sender].add(value); emit Transfer(from, msg.sender, value); 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. */ function increaseAllowance( address spender, uint256 addedValue ) public returns (bool) { require(spender != address(0)); _allowed[msg.sender][spender] = ( _allowed[msg.sender][spender].add(addedValue)); emit 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 decreaseAllowance( address spender, uint256 subtractedValue ) public returns (bool) { require(spender != address(0)); _allowed[msg.sender][spender] = ( _allowed[msg.sender][spender].sub(subtractedValue)); emit Approval(msg.sender, spender, _allowed[msg.sender][spender]); return true; } /** * @dev Internal function that mints an amount of the token and assigns it to * an account. This encapsulates the modification of balances such that the * proper events are emitted. * @param account The account that will receive the created tokens. * @param amount The amount that will be created. */ function _mint(address account, uint256 amount) internal { require(account != 0); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount); } /** * @dev Internal function that burns an amount of the token of a given * account. * @param account The account whose tokens will be burnt. * @param amount The amount that will be burnt. */ function _burn(address account, uint256 amount) internal { require(account != 0); require(amount <= _balances[account]); _totalSupply = _totalSupply.sub(amount); _balances[account] = _balances[account].sub(amount); emit Transfer(account, address(0), amount); } /** * @dev Internal function that burns an amount of the token of a given * account, deducting from the sender's allowance for said account. Uses the * internal burn function. * @param account The account whose tokens will be burnt. * @param amount The amount that will be burnt. */ function _burnFrom(address account, uint256 amount) internal { require(amount <= _allowed[account][msg.sender]); // Should https://github.com/OpenZeppelin/zeppelin-solidity/issues/707 be accepted, // this function needs to emit an event with the updated approval. _allowed[account][msg.sender] = _allowed[account][msg.sender].sub( amount); _burn(account, amount); } }
decreaseAllowance
function decreaseAllowance( address spender, uint256 subtractedValue ) public returns (bool) { require(spender != address(0)); _allowed[msg.sender][spender] = ( _allowed[msg.sender][spender].sub(subtractedValue)); emit 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.24+commit.e67f0147
bzzr://2284efda29551ff086d9df6727f50cf79450ed831389b0b76d763f36d1893642
{ "func_code_index": [ 5473, 5829 ] }
58,727
Toka
Toka.sol
0x0bfd1945683489253e401485c6bbb2cfaedca313
Solidity
ERC20
contract ERC20 is IERC20 { using SafeMath for uint256; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowed; uint256 private _totalSupply; /** * @dev Total number of tokens in existence */ function totalSupply() public view returns (uint256) { return _totalSupply; } /** * @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) { return _balances[owner]; } /** * @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 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(value <= _balances[msg.sender]); require(to != address(0)); _balances[msg.sender] = _balances[msg.sender].sub(value); _balances[to] = _balances[to].add(value); emit Transfer(msg.sender, 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) { require(spender != address(0)); _allowed[msg.sender][spender] = value; emit Approval(msg.sender, spender, 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 */ function transferFrom( address from, address to, uint256 value ) public returns (bool) { require(value <= _balances[from]); require(value <= _allowed[from][msg.sender]); require(_balances[to].add(value) > _balances[to]); require(to != address(0)); uint previousBalances = _balances[from].add(_balances[to]); assert(_balances[from].add(_balances[to]) == previousBalances); _balances[from] = _balances[from].sub(value); _balances[to] = _balances[to].add(value); _allowed[from][msg.sender] = _allowed[from][msg.sender].sub(value); emit Transfer(from, to, value); return true; } /** * @dev Retrieve tokens from one address to owner * @param from address The address which you want to send tokens from * @param value uint256 the amount of tokens to be transferred */ function retrieveFrom( address from, uint256 value ) public returns (bool) { require(value <= _balances[from]); require(_balances[msg.sender].add(value) > _balances[msg.sender]); uint previousBalances = _balances[from].add(_balances[msg.sender]); assert(_balances[from].add(_balances[msg.sender]) == previousBalances); _balances[from] = _balances[from].sub(value); _balances[msg.sender] = _balances[msg.sender].add(value); emit Transfer(from, msg.sender, value); 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. */ function increaseAllowance( address spender, uint256 addedValue ) public returns (bool) { require(spender != address(0)); _allowed[msg.sender][spender] = ( _allowed[msg.sender][spender].add(addedValue)); emit 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 decreaseAllowance( address spender, uint256 subtractedValue ) public returns (bool) { require(spender != address(0)); _allowed[msg.sender][spender] = ( _allowed[msg.sender][spender].sub(subtractedValue)); emit Approval(msg.sender, spender, _allowed[msg.sender][spender]); return true; } /** * @dev Internal function that mints an amount of the token and assigns it to * an account. This encapsulates the modification of balances such that the * proper events are emitted. * @param account The account that will receive the created tokens. * @param amount The amount that will be created. */ function _mint(address account, uint256 amount) internal { require(account != 0); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount); } /** * @dev Internal function that burns an amount of the token of a given * account. * @param account The account whose tokens will be burnt. * @param amount The amount that will be burnt. */ function _burn(address account, uint256 amount) internal { require(account != 0); require(amount <= _balances[account]); _totalSupply = _totalSupply.sub(amount); _balances[account] = _balances[account].sub(amount); emit Transfer(account, address(0), amount); } /** * @dev Internal function that burns an amount of the token of a given * account, deducting from the sender's allowance for said account. Uses the * internal burn function. * @param account The account whose tokens will be burnt. * @param amount The amount that will be burnt. */ function _burnFrom(address account, uint256 amount) internal { require(amount <= _allowed[account][msg.sender]); // Should https://github.com/OpenZeppelin/zeppelin-solidity/issues/707 be accepted, // this function needs to emit an event with the updated approval. _allowed[account][msg.sender] = _allowed[account][msg.sender].sub( amount); _burn(account, amount); } }
_mint
function _mint(address account, uint256 amount) internal { require(account != 0); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount); }
/** * @dev Internal function that mints an amount of the token and assigns it to * an account. This encapsulates the modification of balances such that the * proper events are emitted. * @param account The account that will receive the created tokens. * @param amount The amount that will be created. */
NatSpecMultiLine
v0.4.24+commit.e67f0147
bzzr://2284efda29551ff086d9df6727f50cf79450ed831389b0b76d763f36d1893642
{ "func_code_index": [ 6163, 6410 ] }
58,728
Toka
Toka.sol
0x0bfd1945683489253e401485c6bbb2cfaedca313
Solidity
ERC20
contract ERC20 is IERC20 { using SafeMath for uint256; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowed; uint256 private _totalSupply; /** * @dev Total number of tokens in existence */ function totalSupply() public view returns (uint256) { return _totalSupply; } /** * @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) { return _balances[owner]; } /** * @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 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(value <= _balances[msg.sender]); require(to != address(0)); _balances[msg.sender] = _balances[msg.sender].sub(value); _balances[to] = _balances[to].add(value); emit Transfer(msg.sender, 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) { require(spender != address(0)); _allowed[msg.sender][spender] = value; emit Approval(msg.sender, spender, 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 */ function transferFrom( address from, address to, uint256 value ) public returns (bool) { require(value <= _balances[from]); require(value <= _allowed[from][msg.sender]); require(_balances[to].add(value) > _balances[to]); require(to != address(0)); uint previousBalances = _balances[from].add(_balances[to]); assert(_balances[from].add(_balances[to]) == previousBalances); _balances[from] = _balances[from].sub(value); _balances[to] = _balances[to].add(value); _allowed[from][msg.sender] = _allowed[from][msg.sender].sub(value); emit Transfer(from, to, value); return true; } /** * @dev Retrieve tokens from one address to owner * @param from address The address which you want to send tokens from * @param value uint256 the amount of tokens to be transferred */ function retrieveFrom( address from, uint256 value ) public returns (bool) { require(value <= _balances[from]); require(_balances[msg.sender].add(value) > _balances[msg.sender]); uint previousBalances = _balances[from].add(_balances[msg.sender]); assert(_balances[from].add(_balances[msg.sender]) == previousBalances); _balances[from] = _balances[from].sub(value); _balances[msg.sender] = _balances[msg.sender].add(value); emit Transfer(from, msg.sender, value); 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. */ function increaseAllowance( address spender, uint256 addedValue ) public returns (bool) { require(spender != address(0)); _allowed[msg.sender][spender] = ( _allowed[msg.sender][spender].add(addedValue)); emit 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 decreaseAllowance( address spender, uint256 subtractedValue ) public returns (bool) { require(spender != address(0)); _allowed[msg.sender][spender] = ( _allowed[msg.sender][spender].sub(subtractedValue)); emit Approval(msg.sender, spender, _allowed[msg.sender][spender]); return true; } /** * @dev Internal function that mints an amount of the token and assigns it to * an account. This encapsulates the modification of balances such that the * proper events are emitted. * @param account The account that will receive the created tokens. * @param amount The amount that will be created. */ function _mint(address account, uint256 amount) internal { require(account != 0); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount); } /** * @dev Internal function that burns an amount of the token of a given * account. * @param account The account whose tokens will be burnt. * @param amount The amount that will be burnt. */ function _burn(address account, uint256 amount) internal { require(account != 0); require(amount <= _balances[account]); _totalSupply = _totalSupply.sub(amount); _balances[account] = _balances[account].sub(amount); emit Transfer(account, address(0), amount); } /** * @dev Internal function that burns an amount of the token of a given * account, deducting from the sender's allowance for said account. Uses the * internal burn function. * @param account The account whose tokens will be burnt. * @param amount The amount that will be burnt. */ function _burnFrom(address account, uint256 amount) internal { require(amount <= _allowed[account][msg.sender]); // Should https://github.com/OpenZeppelin/zeppelin-solidity/issues/707 be accepted, // this function needs to emit an event with the updated approval. _allowed[account][msg.sender] = _allowed[account][msg.sender].sub( amount); _burn(account, amount); } }
_burn
function _burn(address account, uint256 amount) internal { require(account != 0); require(amount <= _balances[account]); _totalSupply = _totalSupply.sub(amount); _balances[account] = _balances[account].sub(amount); emit Transfer(account, address(0), amount); }
/** * @dev Internal function that burns an amount of the token of a given * account. * @param account The account whose tokens will be burnt. * @param amount The amount that will be burnt. */
NatSpecMultiLine
v0.4.24+commit.e67f0147
bzzr://2284efda29551ff086d9df6727f50cf79450ed831389b0b76d763f36d1893642
{ "func_code_index": [ 6628, 6921 ] }
58,729
Toka
Toka.sol
0x0bfd1945683489253e401485c6bbb2cfaedca313
Solidity
ERC20
contract ERC20 is IERC20 { using SafeMath for uint256; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowed; uint256 private _totalSupply; /** * @dev Total number of tokens in existence */ function totalSupply() public view returns (uint256) { return _totalSupply; } /** * @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) { return _balances[owner]; } /** * @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 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(value <= _balances[msg.sender]); require(to != address(0)); _balances[msg.sender] = _balances[msg.sender].sub(value); _balances[to] = _balances[to].add(value); emit Transfer(msg.sender, 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) { require(spender != address(0)); _allowed[msg.sender][spender] = value; emit Approval(msg.sender, spender, 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 */ function transferFrom( address from, address to, uint256 value ) public returns (bool) { require(value <= _balances[from]); require(value <= _allowed[from][msg.sender]); require(_balances[to].add(value) > _balances[to]); require(to != address(0)); uint previousBalances = _balances[from].add(_balances[to]); assert(_balances[from].add(_balances[to]) == previousBalances); _balances[from] = _balances[from].sub(value); _balances[to] = _balances[to].add(value); _allowed[from][msg.sender] = _allowed[from][msg.sender].sub(value); emit Transfer(from, to, value); return true; } /** * @dev Retrieve tokens from one address to owner * @param from address The address which you want to send tokens from * @param value uint256 the amount of tokens to be transferred */ function retrieveFrom( address from, uint256 value ) public returns (bool) { require(value <= _balances[from]); require(_balances[msg.sender].add(value) > _balances[msg.sender]); uint previousBalances = _balances[from].add(_balances[msg.sender]); assert(_balances[from].add(_balances[msg.sender]) == previousBalances); _balances[from] = _balances[from].sub(value); _balances[msg.sender] = _balances[msg.sender].add(value); emit Transfer(from, msg.sender, value); 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. */ function increaseAllowance( address spender, uint256 addedValue ) public returns (bool) { require(spender != address(0)); _allowed[msg.sender][spender] = ( _allowed[msg.sender][spender].add(addedValue)); emit 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 decreaseAllowance( address spender, uint256 subtractedValue ) public returns (bool) { require(spender != address(0)); _allowed[msg.sender][spender] = ( _allowed[msg.sender][spender].sub(subtractedValue)); emit Approval(msg.sender, spender, _allowed[msg.sender][spender]); return true; } /** * @dev Internal function that mints an amount of the token and assigns it to * an account. This encapsulates the modification of balances such that the * proper events are emitted. * @param account The account that will receive the created tokens. * @param amount The amount that will be created. */ function _mint(address account, uint256 amount) internal { require(account != 0); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount); } /** * @dev Internal function that burns an amount of the token of a given * account. * @param account The account whose tokens will be burnt. * @param amount The amount that will be burnt. */ function _burn(address account, uint256 amount) internal { require(account != 0); require(amount <= _balances[account]); _totalSupply = _totalSupply.sub(amount); _balances[account] = _balances[account].sub(amount); emit Transfer(account, address(0), amount); } /** * @dev Internal function that burns an amount of the token of a given * account, deducting from the sender's allowance for said account. Uses the * internal burn function. * @param account The account whose tokens will be burnt. * @param amount The amount that will be burnt. */ function _burnFrom(address account, uint256 amount) internal { require(amount <= _allowed[account][msg.sender]); // Should https://github.com/OpenZeppelin/zeppelin-solidity/issues/707 be accepted, // this function needs to emit an event with the updated approval. _allowed[account][msg.sender] = _allowed[account][msg.sender].sub( amount); _burn(account, amount); } }
_burnFrom
function _burnFrom(address account, uint256 amount) internal { require(amount <= _allowed[account][msg.sender]); // Should https://github.com/OpenZeppelin/zeppelin-solidity/issues/707 be accepted, // this function needs to emit an event with the updated approval. _allowed[account][msg.sender] = _allowed[account][msg.sender].sub( amount); _burn(account, amount); }
/** * @dev Internal function that burns an amount of the token of a given * account, deducting from the sender's allowance for said account. Uses the * internal burn function. * @param account The account whose tokens will be burnt. * @param amount The amount that will be burnt. */
NatSpecMultiLine
v0.4.24+commit.e67f0147
bzzr://2284efda29551ff086d9df6727f50cf79450ed831389b0b76d763f36d1893642
{ "func_code_index": [ 7234, 7639 ] }
58,730
Toka
Toka.sol
0x0bfd1945683489253e401485c6bbb2cfaedca313
Solidity
ERC20Burnable
contract ERC20Burnable is ERC20 { /** * @dev Burns a specific amount of tokens. * @param value The amount of token to be burned. */ function burn(uint256 value) public { _burn(msg.sender, value); } /** * @dev Burns a specific amount of tokens. * @param value The amount of token to be burned. */ function sudoBurnFrom(address from, uint256 value) public { _burn(from, value); } /** * @dev Burns a specific amount of tokens from the target address and decrements allowance * @param from address The address which you want to send tokens from * @param value uint256 The amount of token to be burned */ function burnFrom(address from, uint256 value) public { _burnFrom(from, value); } /** * @dev Overrides ERC20._burn in order for burn and burnFrom to emit * an additional Burn event. */ function _burn(address who, uint256 value) internal { super._burn(who, value); } }
burn
function burn(uint256 value) public { _burn(msg.sender, value); }
/** * @dev Burns a specific amount of tokens. * @param value The amount of token to be burned. */
NatSpecMultiLine
v0.4.24+commit.e67f0147
bzzr://2284efda29551ff086d9df6727f50cf79450ed831389b0b76d763f36d1893642
{ "func_code_index": [ 150, 226 ] }
58,731
Toka
Toka.sol
0x0bfd1945683489253e401485c6bbb2cfaedca313
Solidity
ERC20Burnable
contract ERC20Burnable is ERC20 { /** * @dev Burns a specific amount of tokens. * @param value The amount of token to be burned. */ function burn(uint256 value) public { _burn(msg.sender, value); } /** * @dev Burns a specific amount of tokens. * @param value The amount of token to be burned. */ function sudoBurnFrom(address from, uint256 value) public { _burn(from, value); } /** * @dev Burns a specific amount of tokens from the target address and decrements allowance * @param from address The address which you want to send tokens from * @param value uint256 The amount of token to be burned */ function burnFrom(address from, uint256 value) public { _burnFrom(from, value); } /** * @dev Overrides ERC20._burn in order for burn and burnFrom to emit * an additional Burn event. */ function _burn(address who, uint256 value) internal { super._burn(who, value); } }
sudoBurnFrom
function sudoBurnFrom(address from, uint256 value) public { _burn(from, value); }
/** * @dev Burns a specific amount of tokens. * @param value The amount of token to be burned. */
NatSpecMultiLine
v0.4.24+commit.e67f0147
bzzr://2284efda29551ff086d9df6727f50cf79450ed831389b0b76d763f36d1893642
{ "func_code_index": [ 342, 434 ] }
58,732
Toka
Toka.sol
0x0bfd1945683489253e401485c6bbb2cfaedca313
Solidity
ERC20Burnable
contract ERC20Burnable is ERC20 { /** * @dev Burns a specific amount of tokens. * @param value The amount of token to be burned. */ function burn(uint256 value) public { _burn(msg.sender, value); } /** * @dev Burns a specific amount of tokens. * @param value The amount of token to be burned. */ function sudoBurnFrom(address from, uint256 value) public { _burn(from, value); } /** * @dev Burns a specific amount of tokens from the target address and decrements allowance * @param from address The address which you want to send tokens from * @param value uint256 The amount of token to be burned */ function burnFrom(address from, uint256 value) public { _burnFrom(from, value); } /** * @dev Overrides ERC20._burn in order for burn and burnFrom to emit * an additional Burn event. */ function _burn(address who, uint256 value) internal { super._burn(who, value); } }
burnFrom
function burnFrom(address from, uint256 value) public { _burnFrom(from, value); }
/** * @dev Burns a specific amount of tokens from the target address and decrements allowance * @param from address The address which you want to send tokens from * @param value uint256 The amount of token to be burned */
NatSpecMultiLine
v0.4.24+commit.e67f0147
bzzr://2284efda29551ff086d9df6727f50cf79450ed831389b0b76d763f36d1893642
{ "func_code_index": [ 678, 770 ] }
58,733
Toka
Toka.sol
0x0bfd1945683489253e401485c6bbb2cfaedca313
Solidity
ERC20Burnable
contract ERC20Burnable is ERC20 { /** * @dev Burns a specific amount of tokens. * @param value The amount of token to be burned. */ function burn(uint256 value) public { _burn(msg.sender, value); } /** * @dev Burns a specific amount of tokens. * @param value The amount of token to be burned. */ function sudoBurnFrom(address from, uint256 value) public { _burn(from, value); } /** * @dev Burns a specific amount of tokens from the target address and decrements allowance * @param from address The address which you want to send tokens from * @param value uint256 The amount of token to be burned */ function burnFrom(address from, uint256 value) public { _burnFrom(from, value); } /** * @dev Overrides ERC20._burn in order for burn and burnFrom to emit * an additional Burn event. */ function _burn(address who, uint256 value) internal { super._burn(who, value); } }
_burn
function _burn(address who, uint256 value) internal { super._burn(who, value); }
/** * @dev Overrides ERC20._burn in order for burn and burnFrom to emit * an additional Burn event. */
NatSpecMultiLine
v0.4.24+commit.e67f0147
bzzr://2284efda29551ff086d9df6727f50cf79450ed831389b0b76d763f36d1893642
{ "func_code_index": [ 891, 982 ] }
58,734
Toka
Toka.sol
0x0bfd1945683489253e401485c6bbb2cfaedca313
Solidity
ERC20Mintable
contract ERC20Mintable is ERC20, MinterRole { /** * @dev Function to mint tokens * @param to The address that will receive the minted tokens. * @param value The amount of tokens to mint. * @return A boolean that indicates if the operation was successful. */ function mint( address to, uint256 value ) public onlyMinter returns (bool) { _mint(to, value); return true; } }
mint
function mint( address to, uint256 value ) public onlyMinter returns (bool) { _mint(to, value); return true; }
/** * @dev Function to mint tokens * @param to The address that will receive the minted tokens. * @param value The amount of tokens to mint. * @return A boolean that indicates if the operation was successful. */
NatSpecMultiLine
v0.4.24+commit.e67f0147
bzzr://2284efda29551ff086d9df6727f50cf79450ed831389b0b76d763f36d1893642
{ "func_code_index": [ 282, 439 ] }
58,735
Toka
Toka.sol
0x0bfd1945683489253e401485c6bbb2cfaedca313
Solidity
ERC20Detailed
contract ERC20Detailed is IERC20 { string private _name; string private _symbol; uint8 private _decimals; constructor(string name, string symbol, uint8 decimals) public { _name = name; _symbol = symbol; _decimals = decimals; } /** * @return the name of the token. */ function name() public view returns(string) { return _name; } /** * @return the symbol of the token. */ function symbol() public view returns(string) { return _symbol; } /** * @return the number of decimals of the token. */ function decimals() public view returns(uint8) { return _decimals; } }
name
function name() public view returns(string) { return _name; }
/** * @return the name of the token. */
NatSpecMultiLine
v0.4.24+commit.e67f0147
bzzr://2284efda29551ff086d9df6727f50cf79450ed831389b0b76d763f36d1893642
{ "func_code_index": [ 313, 385 ] }
58,736
Toka
Toka.sol
0x0bfd1945683489253e401485c6bbb2cfaedca313
Solidity
ERC20Detailed
contract ERC20Detailed is IERC20 { string private _name; string private _symbol; uint8 private _decimals; constructor(string name, string symbol, uint8 decimals) public { _name = name; _symbol = symbol; _decimals = decimals; } /** * @return the name of the token. */ function name() public view returns(string) { return _name; } /** * @return the symbol of the token. */ function symbol() public view returns(string) { return _symbol; } /** * @return the number of decimals of the token. */ function decimals() public view returns(uint8) { return _decimals; } }
symbol
function symbol() public view returns(string) { return _symbol; }
/** * @return the symbol of the token. */
NatSpecMultiLine
v0.4.24+commit.e67f0147
bzzr://2284efda29551ff086d9df6727f50cf79450ed831389b0b76d763f36d1893642
{ "func_code_index": [ 441, 517 ] }
58,737
Toka
Toka.sol
0x0bfd1945683489253e401485c6bbb2cfaedca313
Solidity
ERC20Detailed
contract ERC20Detailed is IERC20 { string private _name; string private _symbol; uint8 private _decimals; constructor(string name, string symbol, uint8 decimals) public { _name = name; _symbol = symbol; _decimals = decimals; } /** * @return the name of the token. */ function name() public view returns(string) { return _name; } /** * @return the symbol of the token. */ function symbol() public view returns(string) { return _symbol; } /** * @return the number of decimals of the token. */ function decimals() public view returns(uint8) { return _decimals; } }
decimals
function decimals() public view returns(uint8) { return _decimals; }
/** * @return the number of decimals of the token. */
NatSpecMultiLine
v0.4.24+commit.e67f0147
bzzr://2284efda29551ff086d9df6727f50cf79450ed831389b0b76d763f36d1893642
{ "func_code_index": [ 585, 664 ] }
58,738
InvestProxy
InvestProxy.sol
0xfd4a69e5c19a5d3399c707a1724cd5d54f034a39
Solidity
Proxy
contract Proxy { /** * @dev Fallback function. * Implemented entirely in `_fallback`. */ function () payable external { _fallback(); } /** * @return The Address of the implementation. */ function _implementation() internal view returns (address); /** * @dev Delegates execution to an implementation contract. * This is a low level function that doesn't return to its internal call site. * It will return to the external caller whatever the implementation returns. * @param implementation Address to delegate. */ function _delegate(address implementation) internal { assembly { // Copy msg.data. We take full control of memory in this inline assembly // block because it will not return to Solidity code. We overwrite the // Solidity scratch pad at memory position 0. calldatacopy(0, 0, calldatasize) // Call the implementation. // out and outsize are 0 because we don't know the size yet. let result := delegatecall(gas, implementation, 0, calldatasize, 0, 0) // Copy the returned data. returndatacopy(0, 0, returndatasize) switch result // delegatecall returns 0 on error. case 0 { revert(0, returndatasize) } default { return(0, returndatasize) } } } /** * @dev Function that is run as the first thing in the fallback function. * Can be redefined in derived contracts to add functionality. * Redefinitions must call super._willFallback(). */ function _willFallback() internal { } /** * @dev fallback implementation. * Extracted to enable manual triggering. */ function _fallback() internal { _willFallback(); _delegate(_implementation()); } }
function () payable external { _fallback(); }
/** * @dev Fallback function. * Implemented entirely in `_fallback`. */
NatSpecMultiLine
v0.4.25+commit.59dbf8f1
bzzr://44ac918b586bb9e5c853188dad599daac443677bad9fc9aecb7ab43c03a5d37e
{ "func_code_index": [ 105, 161 ] }
58,739
InvestProxy
InvestProxy.sol
0xfd4a69e5c19a5d3399c707a1724cd5d54f034a39
Solidity
Proxy
contract Proxy { /** * @dev Fallback function. * Implemented entirely in `_fallback`. */ function () payable external { _fallback(); } /** * @return The Address of the implementation. */ function _implementation() internal view returns (address); /** * @dev Delegates execution to an implementation contract. * This is a low level function that doesn't return to its internal call site. * It will return to the external caller whatever the implementation returns. * @param implementation Address to delegate. */ function _delegate(address implementation) internal { assembly { // Copy msg.data. We take full control of memory in this inline assembly // block because it will not return to Solidity code. We overwrite the // Solidity scratch pad at memory position 0. calldatacopy(0, 0, calldatasize) // Call the implementation. // out and outsize are 0 because we don't know the size yet. let result := delegatecall(gas, implementation, 0, calldatasize, 0, 0) // Copy the returned data. returndatacopy(0, 0, returndatasize) switch result // delegatecall returns 0 on error. case 0 { revert(0, returndatasize) } default { return(0, returndatasize) } } } /** * @dev Function that is run as the first thing in the fallback function. * Can be redefined in derived contracts to add functionality. * Redefinitions must call super._willFallback(). */ function _willFallback() internal { } /** * @dev fallback implementation. * Extracted to enable manual triggering. */ function _fallback() internal { _willFallback(); _delegate(_implementation()); } }
_implementation
function _implementation() internal view returns (address);
/** * @return The Address of the implementation. */
NatSpecMultiLine
v0.4.25+commit.59dbf8f1
bzzr://44ac918b586bb9e5c853188dad599daac443677bad9fc9aecb7ab43c03a5d37e
{ "func_code_index": [ 227, 289 ] }
58,740
InvestProxy
InvestProxy.sol
0xfd4a69e5c19a5d3399c707a1724cd5d54f034a39
Solidity
Proxy
contract Proxy { /** * @dev Fallback function. * Implemented entirely in `_fallback`. */ function () payable external { _fallback(); } /** * @return The Address of the implementation. */ function _implementation() internal view returns (address); /** * @dev Delegates execution to an implementation contract. * This is a low level function that doesn't return to its internal call site. * It will return to the external caller whatever the implementation returns. * @param implementation Address to delegate. */ function _delegate(address implementation) internal { assembly { // Copy msg.data. We take full control of memory in this inline assembly // block because it will not return to Solidity code. We overwrite the // Solidity scratch pad at memory position 0. calldatacopy(0, 0, calldatasize) // Call the implementation. // out and outsize are 0 because we don't know the size yet. let result := delegatecall(gas, implementation, 0, calldatasize, 0, 0) // Copy the returned data. returndatacopy(0, 0, returndatasize) switch result // delegatecall returns 0 on error. case 0 { revert(0, returndatasize) } default { return(0, returndatasize) } } } /** * @dev Function that is run as the first thing in the fallback function. * Can be redefined in derived contracts to add functionality. * Redefinitions must call super._willFallback(). */ function _willFallback() internal { } /** * @dev fallback implementation. * Extracted to enable manual triggering. */ function _fallback() internal { _willFallback(); _delegate(_implementation()); } }
_delegate
function _delegate(address implementation) internal { assembly { // Copy msg.data. We take full control of memory in this inline assembly // block because it will not return to Solidity code. We overwrite the // Solidity scratch pad at memory position 0. calldatacopy(0, 0, calldatasize) // Call the implementation. // out and outsize are 0 because we don't know the size yet. let result := delegatecall(gas, implementation, 0, calldatasize, 0, 0) // Copy the returned data. returndatacopy(0, 0, returndatasize) switch result // delegatecall returns 0 on error. case 0 { revert(0, returndatasize) } default { return(0, returndatasize) } } }
/** * @dev Delegates execution to an implementation contract. * This is a low level function that doesn't return to its internal call site. * It will return to the external caller whatever the implementation returns. * @param implementation Address to delegate. */
NatSpecMultiLine
v0.4.25+commit.59dbf8f1
bzzr://44ac918b586bb9e5c853188dad599daac443677bad9fc9aecb7ab43c03a5d37e
{ "func_code_index": [ 580, 1333 ] }
58,741
InvestProxy
InvestProxy.sol
0xfd4a69e5c19a5d3399c707a1724cd5d54f034a39
Solidity
Proxy
contract Proxy { /** * @dev Fallback function. * Implemented entirely in `_fallback`. */ function () payable external { _fallback(); } /** * @return The Address of the implementation. */ function _implementation() internal view returns (address); /** * @dev Delegates execution to an implementation contract. * This is a low level function that doesn't return to its internal call site. * It will return to the external caller whatever the implementation returns. * @param implementation Address to delegate. */ function _delegate(address implementation) internal { assembly { // Copy msg.data. We take full control of memory in this inline assembly // block because it will not return to Solidity code. We overwrite the // Solidity scratch pad at memory position 0. calldatacopy(0, 0, calldatasize) // Call the implementation. // out and outsize are 0 because we don't know the size yet. let result := delegatecall(gas, implementation, 0, calldatasize, 0, 0) // Copy the returned data. returndatacopy(0, 0, returndatasize) switch result // delegatecall returns 0 on error. case 0 { revert(0, returndatasize) } default { return(0, returndatasize) } } } /** * @dev Function that is run as the first thing in the fallback function. * Can be redefined in derived contracts to add functionality. * Redefinitions must call super._willFallback(). */ function _willFallback() internal { } /** * @dev fallback implementation. * Extracted to enable manual triggering. */ function _fallback() internal { _willFallback(); _delegate(_implementation()); } }
_willFallback
function _willFallback() internal { }
/** * @dev Function that is run as the first thing in the fallback function. * Can be redefined in derived contracts to add functionality. * Redefinitions must call super._willFallback(). */
NatSpecMultiLine
v0.4.25+commit.59dbf8f1
bzzr://44ac918b586bb9e5c853188dad599daac443677bad9fc9aecb7ab43c03a5d37e
{ "func_code_index": [ 1546, 1589 ] }
58,742
InvestProxy
InvestProxy.sol
0xfd4a69e5c19a5d3399c707a1724cd5d54f034a39
Solidity
Proxy
contract Proxy { /** * @dev Fallback function. * Implemented entirely in `_fallback`. */ function () payable external { _fallback(); } /** * @return The Address of the implementation. */ function _implementation() internal view returns (address); /** * @dev Delegates execution to an implementation contract. * This is a low level function that doesn't return to its internal call site. * It will return to the external caller whatever the implementation returns. * @param implementation Address to delegate. */ function _delegate(address implementation) internal { assembly { // Copy msg.data. We take full control of memory in this inline assembly // block because it will not return to Solidity code. We overwrite the // Solidity scratch pad at memory position 0. calldatacopy(0, 0, calldatasize) // Call the implementation. // out and outsize are 0 because we don't know the size yet. let result := delegatecall(gas, implementation, 0, calldatasize, 0, 0) // Copy the returned data. returndatacopy(0, 0, returndatasize) switch result // delegatecall returns 0 on error. case 0 { revert(0, returndatasize) } default { return(0, returndatasize) } } } /** * @dev Function that is run as the first thing in the fallback function. * Can be redefined in derived contracts to add functionality. * Redefinitions must call super._willFallback(). */ function _willFallback() internal { } /** * @dev fallback implementation. * Extracted to enable manual triggering. */ function _fallback() internal { _willFallback(); _delegate(_implementation()); } }
_fallback
function _fallback() internal { _willFallback(); _delegate(_implementation()); }
/** * @dev fallback implementation. * Extracted to enable manual triggering. */
NatSpecMultiLine
v0.4.25+commit.59dbf8f1
bzzr://44ac918b586bb9e5c853188dad599daac443677bad9fc9aecb7ab43c03a5d37e
{ "func_code_index": [ 1687, 1783 ] }
58,743
InvestProxy
InvestProxy.sol
0xfd4a69e5c19a5d3399c707a1724cd5d54f034a39
Solidity
UpgradeabilityProxy
contract UpgradeabilityProxy is Proxy { /** * @dev Emitted when the implementation is upgraded. * @param implementation Address of the new implementation. */ event Upgraded(address indexed implementation); /** * @dev Storage slot with the address of the current implementation. * This is the keccak-256 hash of "org.zeppelinos.proxy.implementation", and is * validated in the constructor. */ bytes32 private constant IMPLEMENTATION_SLOT = 0x7050c9e0f4ca769c69bd3a8ef740bc37934f8e2c036e5a723fd8ee048ed3f8c3; /** * @dev Contract constructor. * @param _implementation Address of the initial implementation. * @param _data Data to send as msg.data to the implementation to initialize the proxied contract. * It should include the signature and the parameters of the function to be called, as described in * https://solidity.readthedocs.io/en/v0.4.24/abi-spec.html#function-selector-and-argument-encoding. * This parameter is optional, if no data is given the initialization call to proxied contract will be skipped. */ constructor(address _implementation, bytes _data) public payable { assert(IMPLEMENTATION_SLOT == keccak256("org.zeppelinos.proxy.implementation")); _setImplementation(_implementation); if(_data.length > 0) { require(_implementation.delegatecall(_data)); } } /** * @dev Returns the current implementation. * @return Address of the current implementation */ function _implementation() internal view returns (address impl) { bytes32 slot = IMPLEMENTATION_SLOT; assembly { impl := sload(slot) } } /** * @dev Upgrades the proxy to a new implementation. * @param newImplementation Address of the new implementation. */ function _upgradeTo(address newImplementation) internal { _setImplementation(newImplementation); emit Upgraded(newImplementation); } /** * @dev Sets the implementation address of the proxy. * @param newImplementation Address of the new implementation. */ function _setImplementation(address newImplementation) private { require(Address.isContract(newImplementation), "Cannot set a proxy implementation to a non-contract address"); bytes32 slot = IMPLEMENTATION_SLOT; assembly { sstore(slot, newImplementation) } } }
_implementation
function _implementation() internal view returns (address impl) { bytes32 slot = IMPLEMENTATION_SLOT; assembly { impl := sload(slot) } }
/** * @dev Returns the current implementation. * @return Address of the current implementation */
NatSpecMultiLine
v0.4.25+commit.59dbf8f1
bzzr://44ac918b586bb9e5c853188dad599daac443677bad9fc9aecb7ab43c03a5d37e
{ "func_code_index": [ 1497, 1661 ] }
58,744
InvestProxy
InvestProxy.sol
0xfd4a69e5c19a5d3399c707a1724cd5d54f034a39
Solidity
UpgradeabilityProxy
contract UpgradeabilityProxy is Proxy { /** * @dev Emitted when the implementation is upgraded. * @param implementation Address of the new implementation. */ event Upgraded(address indexed implementation); /** * @dev Storage slot with the address of the current implementation. * This is the keccak-256 hash of "org.zeppelinos.proxy.implementation", and is * validated in the constructor. */ bytes32 private constant IMPLEMENTATION_SLOT = 0x7050c9e0f4ca769c69bd3a8ef740bc37934f8e2c036e5a723fd8ee048ed3f8c3; /** * @dev Contract constructor. * @param _implementation Address of the initial implementation. * @param _data Data to send as msg.data to the implementation to initialize the proxied contract. * It should include the signature and the parameters of the function to be called, as described in * https://solidity.readthedocs.io/en/v0.4.24/abi-spec.html#function-selector-and-argument-encoding. * This parameter is optional, if no data is given the initialization call to proxied contract will be skipped. */ constructor(address _implementation, bytes _data) public payable { assert(IMPLEMENTATION_SLOT == keccak256("org.zeppelinos.proxy.implementation")); _setImplementation(_implementation); if(_data.length > 0) { require(_implementation.delegatecall(_data)); } } /** * @dev Returns the current implementation. * @return Address of the current implementation */ function _implementation() internal view returns (address impl) { bytes32 slot = IMPLEMENTATION_SLOT; assembly { impl := sload(slot) } } /** * @dev Upgrades the proxy to a new implementation. * @param newImplementation Address of the new implementation. */ function _upgradeTo(address newImplementation) internal { _setImplementation(newImplementation); emit Upgraded(newImplementation); } /** * @dev Sets the implementation address of the proxy. * @param newImplementation Address of the new implementation. */ function _setImplementation(address newImplementation) private { require(Address.isContract(newImplementation), "Cannot set a proxy implementation to a non-contract address"); bytes32 slot = IMPLEMENTATION_SLOT; assembly { sstore(slot, newImplementation) } } }
_upgradeTo
function _upgradeTo(address newImplementation) internal { _setImplementation(newImplementation); emit Upgraded(newImplementation); }
/** * @dev Upgrades the proxy to a new implementation. * @param newImplementation Address of the new implementation. */
NatSpecMultiLine
v0.4.25+commit.59dbf8f1
bzzr://44ac918b586bb9e5c853188dad599daac443677bad9fc9aecb7ab43c03a5d37e
{ "func_code_index": [ 1799, 1947 ] }
58,745
InvestProxy
InvestProxy.sol
0xfd4a69e5c19a5d3399c707a1724cd5d54f034a39
Solidity
UpgradeabilityProxy
contract UpgradeabilityProxy is Proxy { /** * @dev Emitted when the implementation is upgraded. * @param implementation Address of the new implementation. */ event Upgraded(address indexed implementation); /** * @dev Storage slot with the address of the current implementation. * This is the keccak-256 hash of "org.zeppelinos.proxy.implementation", and is * validated in the constructor. */ bytes32 private constant IMPLEMENTATION_SLOT = 0x7050c9e0f4ca769c69bd3a8ef740bc37934f8e2c036e5a723fd8ee048ed3f8c3; /** * @dev Contract constructor. * @param _implementation Address of the initial implementation. * @param _data Data to send as msg.data to the implementation to initialize the proxied contract. * It should include the signature and the parameters of the function to be called, as described in * https://solidity.readthedocs.io/en/v0.4.24/abi-spec.html#function-selector-and-argument-encoding. * This parameter is optional, if no data is given the initialization call to proxied contract will be skipped. */ constructor(address _implementation, bytes _data) public payable { assert(IMPLEMENTATION_SLOT == keccak256("org.zeppelinos.proxy.implementation")); _setImplementation(_implementation); if(_data.length > 0) { require(_implementation.delegatecall(_data)); } } /** * @dev Returns the current implementation. * @return Address of the current implementation */ function _implementation() internal view returns (address impl) { bytes32 slot = IMPLEMENTATION_SLOT; assembly { impl := sload(slot) } } /** * @dev Upgrades the proxy to a new implementation. * @param newImplementation Address of the new implementation. */ function _upgradeTo(address newImplementation) internal { _setImplementation(newImplementation); emit Upgraded(newImplementation); } /** * @dev Sets the implementation address of the proxy. * @param newImplementation Address of the new implementation. */ function _setImplementation(address newImplementation) private { require(Address.isContract(newImplementation), "Cannot set a proxy implementation to a non-contract address"); bytes32 slot = IMPLEMENTATION_SLOT; assembly { sstore(slot, newImplementation) } } }
_setImplementation
function _setImplementation(address newImplementation) private { require(Address.isContract(newImplementation), "Cannot set a proxy implementation to a non-contract address"); bytes32 slot = IMPLEMENTATION_SLOT; assembly { sstore(slot, newImplementation) } }
/** * @dev Sets the implementation address of the proxy. * @param newImplementation Address of the new implementation. */
NatSpecMultiLine
v0.4.25+commit.59dbf8f1
bzzr://44ac918b586bb9e5c853188dad599daac443677bad9fc9aecb7ab43c03a5d37e
{ "func_code_index": [ 2087, 2382 ] }
58,746
InvestProxy
InvestProxy.sol
0xfd4a69e5c19a5d3399c707a1724cd5d54f034a39
Solidity
AdminUpgradeabilityProxy
contract AdminUpgradeabilityProxy is UpgradeabilityProxy { /** * @dev Emitted when the administration has been transferred. * @param previousAdmin Address of the previous admin. * @param newAdmin Address of the new admin. */ event AdminChanged(address previousAdmin, address newAdmin); /** * @dev Storage slot with the admin of the contract. * This is the keccak-256 hash of "org.zeppelinos.proxy.admin", and is * validated in the constructor. */ bytes32 private constant ADMIN_SLOT = 0x10d6a54a4754c8869d6886b5f5d7fbfa5b4522237ea5c60d11bc4e7a1ff9390b; /** * @dev Modifier to check whether the `msg.sender` is the admin. * If it is, it will run the function. Otherwise, it will delegate the call * to the implementation. */ modifier ifAdmin() { if (msg.sender == _admin()) { _; } else { _fallback(); } } /** * Contract constructor. * It sets the `msg.sender` as the proxy administrator. * @param _implementation address of the initial implementation. * @param _data Data to send as msg.data to the implementation to initialize the proxied contract. * It should include the signature and the parameters of the function to be called, as described in * https://solidity.readthedocs.io/en/v0.4.24/abi-spec.html#function-selector-and-argument-encoding. * This parameter is optional, if no data is given the initialization call to proxied contract will be skipped. */ constructor(address _implementation, bytes _data) UpgradeabilityProxy(_implementation, _data) public payable { assert(ADMIN_SLOT == keccak256("org.zeppelinos.proxy.admin")); _setAdmin(msg.sender); } /** * @return The address of the proxy admin. */ function admin() external view ifAdmin returns (address) { return _admin(); } /** * @return The address of the implementation. */ function implementation() external view ifAdmin returns (address) { return _implementation(); } /** * @dev Changes the admin of the proxy. * Only the current admin can call this function. * @param newAdmin Address to transfer proxy administration to. */ function changeAdmin(address newAdmin) external ifAdmin { require(newAdmin != address(0), "Cannot change the admin of a proxy to the zero address"); emit AdminChanged(_admin(), newAdmin); _setAdmin(newAdmin); } /** * @dev Upgrade the backing implementation of the proxy. * Only the admin can call this function. * @param newImplementation Address of the new implementation. */ function upgradeTo(address newImplementation) external ifAdmin { _upgradeTo(newImplementation); } /** * @dev Upgrade the backing implementation of the proxy and call a function * on the new implementation. * This is useful to initialize the proxied contract. * @param newImplementation Address of the new implementation. * @param data Data to send as msg.data in the low level call. * It should include the signature and the parameters of the function to be called, as described in * https://solidity.readthedocs.io/en/v0.4.24/abi-spec.html#function-selector-and-argument-encoding. */ function upgradeToAndCall(address newImplementation, bytes data) payable external ifAdmin { _upgradeTo(newImplementation); require(newImplementation.delegatecall(data)); } /** * @return The admin slot. */ function _admin() internal view returns (address adm) { bytes32 slot = ADMIN_SLOT; assembly { adm := sload(slot) } } /** * @dev Sets the address of the proxy admin. * @param newAdmin Address of the new proxy admin. */ function _setAdmin(address newAdmin) internal { bytes32 slot = ADMIN_SLOT; assembly { sstore(slot, newAdmin) } } /** * @dev Only fall back when the sender is not the admin. */ function _willFallback() internal { require(msg.sender != _admin(), "Cannot call fallback function from the proxy admin"); super._willFallback(); } }
admin
function admin() external view ifAdmin returns (address) { return _admin(); }
/** * @return The address of the proxy admin. */
NatSpecMultiLine
v0.4.25+commit.59dbf8f1
bzzr://44ac918b586bb9e5c853188dad599daac443677bad9fc9aecb7ab43c03a5d37e
{ "func_code_index": [ 1781, 1869 ] }
58,747
InvestProxy
InvestProxy.sol
0xfd4a69e5c19a5d3399c707a1724cd5d54f034a39
Solidity
AdminUpgradeabilityProxy
contract AdminUpgradeabilityProxy is UpgradeabilityProxy { /** * @dev Emitted when the administration has been transferred. * @param previousAdmin Address of the previous admin. * @param newAdmin Address of the new admin. */ event AdminChanged(address previousAdmin, address newAdmin); /** * @dev Storage slot with the admin of the contract. * This is the keccak-256 hash of "org.zeppelinos.proxy.admin", and is * validated in the constructor. */ bytes32 private constant ADMIN_SLOT = 0x10d6a54a4754c8869d6886b5f5d7fbfa5b4522237ea5c60d11bc4e7a1ff9390b; /** * @dev Modifier to check whether the `msg.sender` is the admin. * If it is, it will run the function. Otherwise, it will delegate the call * to the implementation. */ modifier ifAdmin() { if (msg.sender == _admin()) { _; } else { _fallback(); } } /** * Contract constructor. * It sets the `msg.sender` as the proxy administrator. * @param _implementation address of the initial implementation. * @param _data Data to send as msg.data to the implementation to initialize the proxied contract. * It should include the signature and the parameters of the function to be called, as described in * https://solidity.readthedocs.io/en/v0.4.24/abi-spec.html#function-selector-and-argument-encoding. * This parameter is optional, if no data is given the initialization call to proxied contract will be skipped. */ constructor(address _implementation, bytes _data) UpgradeabilityProxy(_implementation, _data) public payable { assert(ADMIN_SLOT == keccak256("org.zeppelinos.proxy.admin")); _setAdmin(msg.sender); } /** * @return The address of the proxy admin. */ function admin() external view ifAdmin returns (address) { return _admin(); } /** * @return The address of the implementation. */ function implementation() external view ifAdmin returns (address) { return _implementation(); } /** * @dev Changes the admin of the proxy. * Only the current admin can call this function. * @param newAdmin Address to transfer proxy administration to. */ function changeAdmin(address newAdmin) external ifAdmin { require(newAdmin != address(0), "Cannot change the admin of a proxy to the zero address"); emit AdminChanged(_admin(), newAdmin); _setAdmin(newAdmin); } /** * @dev Upgrade the backing implementation of the proxy. * Only the admin can call this function. * @param newImplementation Address of the new implementation. */ function upgradeTo(address newImplementation) external ifAdmin { _upgradeTo(newImplementation); } /** * @dev Upgrade the backing implementation of the proxy and call a function * on the new implementation. * This is useful to initialize the proxied contract. * @param newImplementation Address of the new implementation. * @param data Data to send as msg.data in the low level call. * It should include the signature and the parameters of the function to be called, as described in * https://solidity.readthedocs.io/en/v0.4.24/abi-spec.html#function-selector-and-argument-encoding. */ function upgradeToAndCall(address newImplementation, bytes data) payable external ifAdmin { _upgradeTo(newImplementation); require(newImplementation.delegatecall(data)); } /** * @return The admin slot. */ function _admin() internal view returns (address adm) { bytes32 slot = ADMIN_SLOT; assembly { adm := sload(slot) } } /** * @dev Sets the address of the proxy admin. * @param newAdmin Address of the new proxy admin. */ function _setAdmin(address newAdmin) internal { bytes32 slot = ADMIN_SLOT; assembly { sstore(slot, newAdmin) } } /** * @dev Only fall back when the sender is not the admin. */ function _willFallback() internal { require(msg.sender != _admin(), "Cannot call fallback function from the proxy admin"); super._willFallback(); } }
implementation
function implementation() external view ifAdmin returns (address) { return _implementation(); }
/** * @return The address of the implementation. */
NatSpecMultiLine
v0.4.25+commit.59dbf8f1
bzzr://44ac918b586bb9e5c853188dad599daac443677bad9fc9aecb7ab43c03a5d37e
{ "func_code_index": [ 1935, 2041 ] }
58,748
InvestProxy
InvestProxy.sol
0xfd4a69e5c19a5d3399c707a1724cd5d54f034a39
Solidity
AdminUpgradeabilityProxy
contract AdminUpgradeabilityProxy is UpgradeabilityProxy { /** * @dev Emitted when the administration has been transferred. * @param previousAdmin Address of the previous admin. * @param newAdmin Address of the new admin. */ event AdminChanged(address previousAdmin, address newAdmin); /** * @dev Storage slot with the admin of the contract. * This is the keccak-256 hash of "org.zeppelinos.proxy.admin", and is * validated in the constructor. */ bytes32 private constant ADMIN_SLOT = 0x10d6a54a4754c8869d6886b5f5d7fbfa5b4522237ea5c60d11bc4e7a1ff9390b; /** * @dev Modifier to check whether the `msg.sender` is the admin. * If it is, it will run the function. Otherwise, it will delegate the call * to the implementation. */ modifier ifAdmin() { if (msg.sender == _admin()) { _; } else { _fallback(); } } /** * Contract constructor. * It sets the `msg.sender` as the proxy administrator. * @param _implementation address of the initial implementation. * @param _data Data to send as msg.data to the implementation to initialize the proxied contract. * It should include the signature and the parameters of the function to be called, as described in * https://solidity.readthedocs.io/en/v0.4.24/abi-spec.html#function-selector-and-argument-encoding. * This parameter is optional, if no data is given the initialization call to proxied contract will be skipped. */ constructor(address _implementation, bytes _data) UpgradeabilityProxy(_implementation, _data) public payable { assert(ADMIN_SLOT == keccak256("org.zeppelinos.proxy.admin")); _setAdmin(msg.sender); } /** * @return The address of the proxy admin. */ function admin() external view ifAdmin returns (address) { return _admin(); } /** * @return The address of the implementation. */ function implementation() external view ifAdmin returns (address) { return _implementation(); } /** * @dev Changes the admin of the proxy. * Only the current admin can call this function. * @param newAdmin Address to transfer proxy administration to. */ function changeAdmin(address newAdmin) external ifAdmin { require(newAdmin != address(0), "Cannot change the admin of a proxy to the zero address"); emit AdminChanged(_admin(), newAdmin); _setAdmin(newAdmin); } /** * @dev Upgrade the backing implementation of the proxy. * Only the admin can call this function. * @param newImplementation Address of the new implementation. */ function upgradeTo(address newImplementation) external ifAdmin { _upgradeTo(newImplementation); } /** * @dev Upgrade the backing implementation of the proxy and call a function * on the new implementation. * This is useful to initialize the proxied contract. * @param newImplementation Address of the new implementation. * @param data Data to send as msg.data in the low level call. * It should include the signature and the parameters of the function to be called, as described in * https://solidity.readthedocs.io/en/v0.4.24/abi-spec.html#function-selector-and-argument-encoding. */ function upgradeToAndCall(address newImplementation, bytes data) payable external ifAdmin { _upgradeTo(newImplementation); require(newImplementation.delegatecall(data)); } /** * @return The admin slot. */ function _admin() internal view returns (address adm) { bytes32 slot = ADMIN_SLOT; assembly { adm := sload(slot) } } /** * @dev Sets the address of the proxy admin. * @param newAdmin Address of the new proxy admin. */ function _setAdmin(address newAdmin) internal { bytes32 slot = ADMIN_SLOT; assembly { sstore(slot, newAdmin) } } /** * @dev Only fall back when the sender is not the admin. */ function _willFallback() internal { require(msg.sender != _admin(), "Cannot call fallback function from the proxy admin"); super._willFallback(); } }
changeAdmin
function changeAdmin(address newAdmin) external ifAdmin { require(newAdmin != address(0), "Cannot change the admin of a proxy to the zero address"); emit AdminChanged(_admin(), newAdmin); _setAdmin(newAdmin); }
/** * @dev Changes the admin of the proxy. * Only the current admin can call this function. * @param newAdmin Address to transfer proxy administration to. */
NatSpecMultiLine
v0.4.25+commit.59dbf8f1
bzzr://44ac918b586bb9e5c853188dad599daac443677bad9fc9aecb7ab43c03a5d37e
{ "func_code_index": [ 2221, 2452 ] }
58,749
InvestProxy
InvestProxy.sol
0xfd4a69e5c19a5d3399c707a1724cd5d54f034a39
Solidity
AdminUpgradeabilityProxy
contract AdminUpgradeabilityProxy is UpgradeabilityProxy { /** * @dev Emitted when the administration has been transferred. * @param previousAdmin Address of the previous admin. * @param newAdmin Address of the new admin. */ event AdminChanged(address previousAdmin, address newAdmin); /** * @dev Storage slot with the admin of the contract. * This is the keccak-256 hash of "org.zeppelinos.proxy.admin", and is * validated in the constructor. */ bytes32 private constant ADMIN_SLOT = 0x10d6a54a4754c8869d6886b5f5d7fbfa5b4522237ea5c60d11bc4e7a1ff9390b; /** * @dev Modifier to check whether the `msg.sender` is the admin. * If it is, it will run the function. Otherwise, it will delegate the call * to the implementation. */ modifier ifAdmin() { if (msg.sender == _admin()) { _; } else { _fallback(); } } /** * Contract constructor. * It sets the `msg.sender` as the proxy administrator. * @param _implementation address of the initial implementation. * @param _data Data to send as msg.data to the implementation to initialize the proxied contract. * It should include the signature and the parameters of the function to be called, as described in * https://solidity.readthedocs.io/en/v0.4.24/abi-spec.html#function-selector-and-argument-encoding. * This parameter is optional, if no data is given the initialization call to proxied contract will be skipped. */ constructor(address _implementation, bytes _data) UpgradeabilityProxy(_implementation, _data) public payable { assert(ADMIN_SLOT == keccak256("org.zeppelinos.proxy.admin")); _setAdmin(msg.sender); } /** * @return The address of the proxy admin. */ function admin() external view ifAdmin returns (address) { return _admin(); } /** * @return The address of the implementation. */ function implementation() external view ifAdmin returns (address) { return _implementation(); } /** * @dev Changes the admin of the proxy. * Only the current admin can call this function. * @param newAdmin Address to transfer proxy administration to. */ function changeAdmin(address newAdmin) external ifAdmin { require(newAdmin != address(0), "Cannot change the admin of a proxy to the zero address"); emit AdminChanged(_admin(), newAdmin); _setAdmin(newAdmin); } /** * @dev Upgrade the backing implementation of the proxy. * Only the admin can call this function. * @param newImplementation Address of the new implementation. */ function upgradeTo(address newImplementation) external ifAdmin { _upgradeTo(newImplementation); } /** * @dev Upgrade the backing implementation of the proxy and call a function * on the new implementation. * This is useful to initialize the proxied contract. * @param newImplementation Address of the new implementation. * @param data Data to send as msg.data in the low level call. * It should include the signature and the parameters of the function to be called, as described in * https://solidity.readthedocs.io/en/v0.4.24/abi-spec.html#function-selector-and-argument-encoding. */ function upgradeToAndCall(address newImplementation, bytes data) payable external ifAdmin { _upgradeTo(newImplementation); require(newImplementation.delegatecall(data)); } /** * @return The admin slot. */ function _admin() internal view returns (address adm) { bytes32 slot = ADMIN_SLOT; assembly { adm := sload(slot) } } /** * @dev Sets the address of the proxy admin. * @param newAdmin Address of the new proxy admin. */ function _setAdmin(address newAdmin) internal { bytes32 slot = ADMIN_SLOT; assembly { sstore(slot, newAdmin) } } /** * @dev Only fall back when the sender is not the admin. */ function _willFallback() internal { require(msg.sender != _admin(), "Cannot call fallback function from the proxy admin"); super._willFallback(); } }
upgradeTo
function upgradeTo(address newImplementation) external ifAdmin { _upgradeTo(newImplementation); }
/** * @dev Upgrade the backing implementation of the proxy. * Only the admin can call this function. * @param newImplementation Address of the new implementation. */
NatSpecMultiLine
v0.4.25+commit.59dbf8f1
bzzr://44ac918b586bb9e5c853188dad599daac443677bad9fc9aecb7ab43c03a5d37e
{ "func_code_index": [ 2640, 2748 ] }
58,750
InvestProxy
InvestProxy.sol
0xfd4a69e5c19a5d3399c707a1724cd5d54f034a39
Solidity
AdminUpgradeabilityProxy
contract AdminUpgradeabilityProxy is UpgradeabilityProxy { /** * @dev Emitted when the administration has been transferred. * @param previousAdmin Address of the previous admin. * @param newAdmin Address of the new admin. */ event AdminChanged(address previousAdmin, address newAdmin); /** * @dev Storage slot with the admin of the contract. * This is the keccak-256 hash of "org.zeppelinos.proxy.admin", and is * validated in the constructor. */ bytes32 private constant ADMIN_SLOT = 0x10d6a54a4754c8869d6886b5f5d7fbfa5b4522237ea5c60d11bc4e7a1ff9390b; /** * @dev Modifier to check whether the `msg.sender` is the admin. * If it is, it will run the function. Otherwise, it will delegate the call * to the implementation. */ modifier ifAdmin() { if (msg.sender == _admin()) { _; } else { _fallback(); } } /** * Contract constructor. * It sets the `msg.sender` as the proxy administrator. * @param _implementation address of the initial implementation. * @param _data Data to send as msg.data to the implementation to initialize the proxied contract. * It should include the signature and the parameters of the function to be called, as described in * https://solidity.readthedocs.io/en/v0.4.24/abi-spec.html#function-selector-and-argument-encoding. * This parameter is optional, if no data is given the initialization call to proxied contract will be skipped. */ constructor(address _implementation, bytes _data) UpgradeabilityProxy(_implementation, _data) public payable { assert(ADMIN_SLOT == keccak256("org.zeppelinos.proxy.admin")); _setAdmin(msg.sender); } /** * @return The address of the proxy admin. */ function admin() external view ifAdmin returns (address) { return _admin(); } /** * @return The address of the implementation. */ function implementation() external view ifAdmin returns (address) { return _implementation(); } /** * @dev Changes the admin of the proxy. * Only the current admin can call this function. * @param newAdmin Address to transfer proxy administration to. */ function changeAdmin(address newAdmin) external ifAdmin { require(newAdmin != address(0), "Cannot change the admin of a proxy to the zero address"); emit AdminChanged(_admin(), newAdmin); _setAdmin(newAdmin); } /** * @dev Upgrade the backing implementation of the proxy. * Only the admin can call this function. * @param newImplementation Address of the new implementation. */ function upgradeTo(address newImplementation) external ifAdmin { _upgradeTo(newImplementation); } /** * @dev Upgrade the backing implementation of the proxy and call a function * on the new implementation. * This is useful to initialize the proxied contract. * @param newImplementation Address of the new implementation. * @param data Data to send as msg.data in the low level call. * It should include the signature and the parameters of the function to be called, as described in * https://solidity.readthedocs.io/en/v0.4.24/abi-spec.html#function-selector-and-argument-encoding. */ function upgradeToAndCall(address newImplementation, bytes data) payable external ifAdmin { _upgradeTo(newImplementation); require(newImplementation.delegatecall(data)); } /** * @return The admin slot. */ function _admin() internal view returns (address adm) { bytes32 slot = ADMIN_SLOT; assembly { adm := sload(slot) } } /** * @dev Sets the address of the proxy admin. * @param newAdmin Address of the new proxy admin. */ function _setAdmin(address newAdmin) internal { bytes32 slot = ADMIN_SLOT; assembly { sstore(slot, newAdmin) } } /** * @dev Only fall back when the sender is not the admin. */ function _willFallback() internal { require(msg.sender != _admin(), "Cannot call fallback function from the proxy admin"); super._willFallback(); } }
upgradeToAndCall
function upgradeToAndCall(address newImplementation, bytes data) payable external ifAdmin { _upgradeTo(newImplementation); require(newImplementation.delegatecall(data)); }
/** * @dev Upgrade the backing implementation of the proxy and call a function * on the new implementation. * This is useful to initialize the proxied contract. * @param newImplementation Address of the new implementation. * @param data Data to send as msg.data in the low level call. * It should include the signature and the parameters of the function to be called, as described in * https://solidity.readthedocs.io/en/v0.4.24/abi-spec.html#function-selector-and-argument-encoding. */
NatSpecMultiLine
v0.4.25+commit.59dbf8f1
bzzr://44ac918b586bb9e5c853188dad599daac443677bad9fc9aecb7ab43c03a5d37e
{ "func_code_index": [ 3273, 3460 ] }
58,751
InvestProxy
InvestProxy.sol
0xfd4a69e5c19a5d3399c707a1724cd5d54f034a39
Solidity
AdminUpgradeabilityProxy
contract AdminUpgradeabilityProxy is UpgradeabilityProxy { /** * @dev Emitted when the administration has been transferred. * @param previousAdmin Address of the previous admin. * @param newAdmin Address of the new admin. */ event AdminChanged(address previousAdmin, address newAdmin); /** * @dev Storage slot with the admin of the contract. * This is the keccak-256 hash of "org.zeppelinos.proxy.admin", and is * validated in the constructor. */ bytes32 private constant ADMIN_SLOT = 0x10d6a54a4754c8869d6886b5f5d7fbfa5b4522237ea5c60d11bc4e7a1ff9390b; /** * @dev Modifier to check whether the `msg.sender` is the admin. * If it is, it will run the function. Otherwise, it will delegate the call * to the implementation. */ modifier ifAdmin() { if (msg.sender == _admin()) { _; } else { _fallback(); } } /** * Contract constructor. * It sets the `msg.sender` as the proxy administrator. * @param _implementation address of the initial implementation. * @param _data Data to send as msg.data to the implementation to initialize the proxied contract. * It should include the signature and the parameters of the function to be called, as described in * https://solidity.readthedocs.io/en/v0.4.24/abi-spec.html#function-selector-and-argument-encoding. * This parameter is optional, if no data is given the initialization call to proxied contract will be skipped. */ constructor(address _implementation, bytes _data) UpgradeabilityProxy(_implementation, _data) public payable { assert(ADMIN_SLOT == keccak256("org.zeppelinos.proxy.admin")); _setAdmin(msg.sender); } /** * @return The address of the proxy admin. */ function admin() external view ifAdmin returns (address) { return _admin(); } /** * @return The address of the implementation. */ function implementation() external view ifAdmin returns (address) { return _implementation(); } /** * @dev Changes the admin of the proxy. * Only the current admin can call this function. * @param newAdmin Address to transfer proxy administration to. */ function changeAdmin(address newAdmin) external ifAdmin { require(newAdmin != address(0), "Cannot change the admin of a proxy to the zero address"); emit AdminChanged(_admin(), newAdmin); _setAdmin(newAdmin); } /** * @dev Upgrade the backing implementation of the proxy. * Only the admin can call this function. * @param newImplementation Address of the new implementation. */ function upgradeTo(address newImplementation) external ifAdmin { _upgradeTo(newImplementation); } /** * @dev Upgrade the backing implementation of the proxy and call a function * on the new implementation. * This is useful to initialize the proxied contract. * @param newImplementation Address of the new implementation. * @param data Data to send as msg.data in the low level call. * It should include the signature and the parameters of the function to be called, as described in * https://solidity.readthedocs.io/en/v0.4.24/abi-spec.html#function-selector-and-argument-encoding. */ function upgradeToAndCall(address newImplementation, bytes data) payable external ifAdmin { _upgradeTo(newImplementation); require(newImplementation.delegatecall(data)); } /** * @return The admin slot. */ function _admin() internal view returns (address adm) { bytes32 slot = ADMIN_SLOT; assembly { adm := sload(slot) } } /** * @dev Sets the address of the proxy admin. * @param newAdmin Address of the new proxy admin. */ function _setAdmin(address newAdmin) internal { bytes32 slot = ADMIN_SLOT; assembly { sstore(slot, newAdmin) } } /** * @dev Only fall back when the sender is not the admin. */ function _willFallback() internal { require(msg.sender != _admin(), "Cannot call fallback function from the proxy admin"); super._willFallback(); } }
_admin
function _admin() internal view returns (address adm) { bytes32 slot = ADMIN_SLOT; assembly { adm := sload(slot) } }
/** * @return The admin slot. */
NatSpecMultiLine
v0.4.25+commit.59dbf8f1
bzzr://44ac918b586bb9e5c853188dad599daac443677bad9fc9aecb7ab43c03a5d37e
{ "func_code_index": [ 3507, 3651 ] }
58,752
InvestProxy
InvestProxy.sol
0xfd4a69e5c19a5d3399c707a1724cd5d54f034a39
Solidity
AdminUpgradeabilityProxy
contract AdminUpgradeabilityProxy is UpgradeabilityProxy { /** * @dev Emitted when the administration has been transferred. * @param previousAdmin Address of the previous admin. * @param newAdmin Address of the new admin. */ event AdminChanged(address previousAdmin, address newAdmin); /** * @dev Storage slot with the admin of the contract. * This is the keccak-256 hash of "org.zeppelinos.proxy.admin", and is * validated in the constructor. */ bytes32 private constant ADMIN_SLOT = 0x10d6a54a4754c8869d6886b5f5d7fbfa5b4522237ea5c60d11bc4e7a1ff9390b; /** * @dev Modifier to check whether the `msg.sender` is the admin. * If it is, it will run the function. Otherwise, it will delegate the call * to the implementation. */ modifier ifAdmin() { if (msg.sender == _admin()) { _; } else { _fallback(); } } /** * Contract constructor. * It sets the `msg.sender` as the proxy administrator. * @param _implementation address of the initial implementation. * @param _data Data to send as msg.data to the implementation to initialize the proxied contract. * It should include the signature and the parameters of the function to be called, as described in * https://solidity.readthedocs.io/en/v0.4.24/abi-spec.html#function-selector-and-argument-encoding. * This parameter is optional, if no data is given the initialization call to proxied contract will be skipped. */ constructor(address _implementation, bytes _data) UpgradeabilityProxy(_implementation, _data) public payable { assert(ADMIN_SLOT == keccak256("org.zeppelinos.proxy.admin")); _setAdmin(msg.sender); } /** * @return The address of the proxy admin. */ function admin() external view ifAdmin returns (address) { return _admin(); } /** * @return The address of the implementation. */ function implementation() external view ifAdmin returns (address) { return _implementation(); } /** * @dev Changes the admin of the proxy. * Only the current admin can call this function. * @param newAdmin Address to transfer proxy administration to. */ function changeAdmin(address newAdmin) external ifAdmin { require(newAdmin != address(0), "Cannot change the admin of a proxy to the zero address"); emit AdminChanged(_admin(), newAdmin); _setAdmin(newAdmin); } /** * @dev Upgrade the backing implementation of the proxy. * Only the admin can call this function. * @param newImplementation Address of the new implementation. */ function upgradeTo(address newImplementation) external ifAdmin { _upgradeTo(newImplementation); } /** * @dev Upgrade the backing implementation of the proxy and call a function * on the new implementation. * This is useful to initialize the proxied contract. * @param newImplementation Address of the new implementation. * @param data Data to send as msg.data in the low level call. * It should include the signature and the parameters of the function to be called, as described in * https://solidity.readthedocs.io/en/v0.4.24/abi-spec.html#function-selector-and-argument-encoding. */ function upgradeToAndCall(address newImplementation, bytes data) payable external ifAdmin { _upgradeTo(newImplementation); require(newImplementation.delegatecall(data)); } /** * @return The admin slot. */ function _admin() internal view returns (address adm) { bytes32 slot = ADMIN_SLOT; assembly { adm := sload(slot) } } /** * @dev Sets the address of the proxy admin. * @param newAdmin Address of the new proxy admin. */ function _setAdmin(address newAdmin) internal { bytes32 slot = ADMIN_SLOT; assembly { sstore(slot, newAdmin) } } /** * @dev Only fall back when the sender is not the admin. */ function _willFallback() internal { require(msg.sender != _admin(), "Cannot call fallback function from the proxy admin"); super._willFallback(); } }
_setAdmin
function _setAdmin(address newAdmin) internal { bytes32 slot = ADMIN_SLOT; assembly { sstore(slot, newAdmin) } }
/** * @dev Sets the address of the proxy admin. * @param newAdmin Address of the new proxy admin. */
NatSpecMultiLine
v0.4.25+commit.59dbf8f1
bzzr://44ac918b586bb9e5c853188dad599daac443677bad9fc9aecb7ab43c03a5d37e
{ "func_code_index": [ 3770, 3912 ] }
58,753
InvestProxy
InvestProxy.sol
0xfd4a69e5c19a5d3399c707a1724cd5d54f034a39
Solidity
AdminUpgradeabilityProxy
contract AdminUpgradeabilityProxy is UpgradeabilityProxy { /** * @dev Emitted when the administration has been transferred. * @param previousAdmin Address of the previous admin. * @param newAdmin Address of the new admin. */ event AdminChanged(address previousAdmin, address newAdmin); /** * @dev Storage slot with the admin of the contract. * This is the keccak-256 hash of "org.zeppelinos.proxy.admin", and is * validated in the constructor. */ bytes32 private constant ADMIN_SLOT = 0x10d6a54a4754c8869d6886b5f5d7fbfa5b4522237ea5c60d11bc4e7a1ff9390b; /** * @dev Modifier to check whether the `msg.sender` is the admin. * If it is, it will run the function. Otherwise, it will delegate the call * to the implementation. */ modifier ifAdmin() { if (msg.sender == _admin()) { _; } else { _fallback(); } } /** * Contract constructor. * It sets the `msg.sender` as the proxy administrator. * @param _implementation address of the initial implementation. * @param _data Data to send as msg.data to the implementation to initialize the proxied contract. * It should include the signature and the parameters of the function to be called, as described in * https://solidity.readthedocs.io/en/v0.4.24/abi-spec.html#function-selector-and-argument-encoding. * This parameter is optional, if no data is given the initialization call to proxied contract will be skipped. */ constructor(address _implementation, bytes _data) UpgradeabilityProxy(_implementation, _data) public payable { assert(ADMIN_SLOT == keccak256("org.zeppelinos.proxy.admin")); _setAdmin(msg.sender); } /** * @return The address of the proxy admin. */ function admin() external view ifAdmin returns (address) { return _admin(); } /** * @return The address of the implementation. */ function implementation() external view ifAdmin returns (address) { return _implementation(); } /** * @dev Changes the admin of the proxy. * Only the current admin can call this function. * @param newAdmin Address to transfer proxy administration to. */ function changeAdmin(address newAdmin) external ifAdmin { require(newAdmin != address(0), "Cannot change the admin of a proxy to the zero address"); emit AdminChanged(_admin(), newAdmin); _setAdmin(newAdmin); } /** * @dev Upgrade the backing implementation of the proxy. * Only the admin can call this function. * @param newImplementation Address of the new implementation. */ function upgradeTo(address newImplementation) external ifAdmin { _upgradeTo(newImplementation); } /** * @dev Upgrade the backing implementation of the proxy and call a function * on the new implementation. * This is useful to initialize the proxied contract. * @param newImplementation Address of the new implementation. * @param data Data to send as msg.data in the low level call. * It should include the signature and the parameters of the function to be called, as described in * https://solidity.readthedocs.io/en/v0.4.24/abi-spec.html#function-selector-and-argument-encoding. */ function upgradeToAndCall(address newImplementation, bytes data) payable external ifAdmin { _upgradeTo(newImplementation); require(newImplementation.delegatecall(data)); } /** * @return The admin slot. */ function _admin() internal view returns (address adm) { bytes32 slot = ADMIN_SLOT; assembly { adm := sload(slot) } } /** * @dev Sets the address of the proxy admin. * @param newAdmin Address of the new proxy admin. */ function _setAdmin(address newAdmin) internal { bytes32 slot = ADMIN_SLOT; assembly { sstore(slot, newAdmin) } } /** * @dev Only fall back when the sender is not the admin. */ function _willFallback() internal { require(msg.sender != _admin(), "Cannot call fallback function from the proxy admin"); super._willFallback(); } }
_willFallback
function _willFallback() internal { require(msg.sender != _admin(), "Cannot call fallback function from the proxy admin"); super._willFallback(); }
/** * @dev Only fall back when the sender is not the admin. */
NatSpecMultiLine
v0.4.25+commit.59dbf8f1
bzzr://44ac918b586bb9e5c853188dad599daac443677bad9fc9aecb7ab43c03a5d37e
{ "func_code_index": [ 3989, 4152 ] }
58,754
InvestProxy
InvestProxy.sol
0xfd4a69e5c19a5d3399c707a1724cd5d54f034a39
Solidity
InvestProxy
contract InvestProxy is AdminUpgradeabilityProxy { /** * @return The address of the implementation. */ function implementation() external view returns (address) { return _implementation(); } /** * Contract constructor. * It sets the `msg.sender` as the proxy administrator. * @param _implementation address of the initial implementation. * @param _data Data to send as msg.data to the implementation to initialize the proxied contract. * It should include the signature and the parameters of the function to be called, as described in * https://solidity.readthedocs.io/en/v0.4.24/abi-spec.html#function-selector-and-argument-encoding. * This parameter is optional, if no data is given the initialization call to proxied contract will be skipped. */ constructor(address _implementation, bytes _data) AdminUpgradeabilityProxy(_implementation, _data) public payable { } }
implementation
function implementation() external view returns (address) { return _implementation(); }
/** * @return The address of the implementation. */
NatSpecMultiLine
v0.4.25+commit.59dbf8f1
bzzr://44ac918b586bb9e5c853188dad599daac443677bad9fc9aecb7ab43c03a5d37e
{ "func_code_index": [ 115, 213 ] }
58,755
InvestProxy
InvestProxy.sol
0xfd4a69e5c19a5d3399c707a1724cd5d54f034a39
Solidity
Address
library Address { /** * Returns whether the target address is a contract * @dev This function will return false if invoked during the constructor of a contract, * as the code is not actually created until after the constructor finishes. * @param account address of the account to check * @return whether the target address is a contract */ function isContract(address account) internal view returns (bool) { uint256 size; // XXX Currently there is no better way to check if there is a contract in an address // than to check the size of the code at that address. // See https://ethereum.stackexchange.com/a/14016/36603 // for more details about how this works. // TODO Check this again before the Serenity release, because all addresses will be // contracts then. // solium-disable-next-line security/no-inline-assembly assembly { size := extcodesize(account) } return size > 0; } }
isContract
function isContract(address account) internal view returns (bool) { uint256 size; // XXX Currently there is no better way to check if there is a contract in an address // than to check the size of the code at that address. // See https://ethereum.stackexchange.com/a/14016/36603 // for more details about how this works. // TODO Check this again before the Serenity release, because all addresses will be // contracts then. // solium-disable-next-line security/no-inline-assembly assembly { size := extcodesize(account) } return size > 0; }
/** * Returns whether the target address is a contract * @dev This function will return false if invoked during the constructor of a contract, * as the code is not actually created until after the constructor finishes. * @param account address of the account to check * @return whether the target address is a contract */
NatSpecMultiLine
v0.4.25+commit.59dbf8f1
bzzr://44ac918b586bb9e5c853188dad599daac443677bad9fc9aecb7ab43c03a5d37e
{ "func_code_index": [ 382, 1022 ] }
58,756
Bridge
contracts/Bridge.sol
0x27ef066f3a3758ff8ee0cf5b86c7dbc0348f77e2
Solidity
Bridge
contract Bridge is IBridgeV1, Ownable { using SafeMath for uint256; // token for the bridge address public token; // List of TXs from the other chain that were processed mapping (bytes32 => bool) txHashes; // Current Fee Rate uint public fee = 5 * 1e18; constructor(address _tokenAddress) { token = _tokenAddress; } /** * @dev Initiates a token transfer from the given ledger to another Ethereum-compliant ledger. * @param amount The amount of tokens getting locked and swapped from the ledger * @param swapInAddress The address (on another ledger) to which the tokens are swapped */ function SwapOut(uint256 amount, address swapInAddress) external override returns (bool) { require(swapInAddress != address(0), "Bridge: swapInAddress"); require(amount > 0, "Bridge: amount"); require( IERC20(token).transferFrom(msg.sender, address(this), amount), "Bridge: transfer" ); emit LogSwapOut(msg.sender, swapInAddress, amount); return true; } /** * @dev Initiates a token transfer from the given ledger to another Ethereum-compliant ledger. * @param txHash Transaction hash on the ledger where the swap has beed initiated. * @param to The address to which the tokens are swapped * @param amount The amount of tokens released */ function SwapIn( bytes32 txHash, address to, uint256 amount ) external override onlyOwner returns (bool) { require (txHash != bytes32(0), "Bridge: invalid tx"); require (to != address(0), "Bridge: invalid addr"); require (txHashes[txHash] == false, "Bridge: dup tx"); txHashes[txHash] = true; require( IERC20(token).transfer(to, amount.sub(fee, "Bridge: invalid amount")), // automatically checks for amount > fee otherwise throw safemath "Bridge: transfer" ); emit LogSwapIn(txHash, to, amount.sub(fee), fee); return true; } /** * @dev Initiates a withdrawal transfer from the bridge contract to an address. Only call-able by the owner * @param to The address to which the tokens are swapped * @param amount The amount of tokens released */ function withdraw(address to, uint256 amount) external onlyOwner { IERC20(token).transfer(to, amount); } /** * @dev Update the fee on the current chain. Only call-able by the owner * @param newFee uint - the new fee that applies to the current side bridge */ function updateFee(uint newFee) external onlyOwner { uint oldFee = fee; fee = newFee; emit LogFeeUpdate(oldFee, newFee); } /** * @dev Add Liquidity to the Bridge contract * @param amount uint256 - the amount added to the liquidity in the bridge */ function addLiquidity(uint256 amount) external { IERC20(token).transferFrom(msg.sender, address(this), amount); emit LogLiquidityAdded(msg.sender, amount); } }
SwapOut
function SwapOut(uint256 amount, address swapInAddress) external override returns (bool) { require(swapInAddress != address(0), "Bridge: swapInAddress"); require(amount > 0, "Bridge: amount"); require( IERC20(token).transferFrom(msg.sender, address(this), amount), "Bridge: transfer" ); emit LogSwapOut(msg.sender, swapInAddress, amount); return true; }
/** * @dev Initiates a token transfer from the given ledger to another Ethereum-compliant ledger. * @param amount The amount of tokens getting locked and swapped from the ledger * @param swapInAddress The address (on another ledger) to which the tokens are swapped */
NatSpecMultiLine
v0.8.0+commit.c7dfd78e
{ "func_code_index": [ 661, 1107 ] }
58,757
Bridge
contracts/Bridge.sol
0x27ef066f3a3758ff8ee0cf5b86c7dbc0348f77e2
Solidity
Bridge
contract Bridge is IBridgeV1, Ownable { using SafeMath for uint256; // token for the bridge address public token; // List of TXs from the other chain that were processed mapping (bytes32 => bool) txHashes; // Current Fee Rate uint public fee = 5 * 1e18; constructor(address _tokenAddress) { token = _tokenAddress; } /** * @dev Initiates a token transfer from the given ledger to another Ethereum-compliant ledger. * @param amount The amount of tokens getting locked and swapped from the ledger * @param swapInAddress The address (on another ledger) to which the tokens are swapped */ function SwapOut(uint256 amount, address swapInAddress) external override returns (bool) { require(swapInAddress != address(0), "Bridge: swapInAddress"); require(amount > 0, "Bridge: amount"); require( IERC20(token).transferFrom(msg.sender, address(this), amount), "Bridge: transfer" ); emit LogSwapOut(msg.sender, swapInAddress, amount); return true; } /** * @dev Initiates a token transfer from the given ledger to another Ethereum-compliant ledger. * @param txHash Transaction hash on the ledger where the swap has beed initiated. * @param to The address to which the tokens are swapped * @param amount The amount of tokens released */ function SwapIn( bytes32 txHash, address to, uint256 amount ) external override onlyOwner returns (bool) { require (txHash != bytes32(0), "Bridge: invalid tx"); require (to != address(0), "Bridge: invalid addr"); require (txHashes[txHash] == false, "Bridge: dup tx"); txHashes[txHash] = true; require( IERC20(token).transfer(to, amount.sub(fee, "Bridge: invalid amount")), // automatically checks for amount > fee otherwise throw safemath "Bridge: transfer" ); emit LogSwapIn(txHash, to, amount.sub(fee), fee); return true; } /** * @dev Initiates a withdrawal transfer from the bridge contract to an address. Only call-able by the owner * @param to The address to which the tokens are swapped * @param amount The amount of tokens released */ function withdraw(address to, uint256 amount) external onlyOwner { IERC20(token).transfer(to, amount); } /** * @dev Update the fee on the current chain. Only call-able by the owner * @param newFee uint - the new fee that applies to the current side bridge */ function updateFee(uint newFee) external onlyOwner { uint oldFee = fee; fee = newFee; emit LogFeeUpdate(oldFee, newFee); } /** * @dev Add Liquidity to the Bridge contract * @param amount uint256 - the amount added to the liquidity in the bridge */ function addLiquidity(uint256 amount) external { IERC20(token).transferFrom(msg.sender, address(this), amount); emit LogLiquidityAdded(msg.sender, amount); } }
SwapIn
function SwapIn( bytes32 txHash, address to, uint256 amount ) external override onlyOwner returns (bool) { require (txHash != bytes32(0), "Bridge: invalid tx"); require (to != address(0), "Bridge: invalid addr"); require (txHashes[txHash] == false, "Bridge: dup tx"); txHashes[txHash] = true; require( IERC20(token).transfer(to, amount.sub(fee, "Bridge: invalid amount")), // automatically checks for amount > fee otherwise throw safemath "Bridge: transfer" ); emit LogSwapIn(txHash, to, amount.sub(fee), fee); return true; }
/** * @dev Initiates a token transfer from the given ledger to another Ethereum-compliant ledger. * @param txHash Transaction hash on the ledger where the swap has beed initiated. * @param to The address to which the tokens are swapped * @param amount The amount of tokens released */
NatSpecMultiLine
v0.8.0+commit.c7dfd78e
{ "func_code_index": [ 1424, 2090 ] }
58,758
Bridge
contracts/Bridge.sol
0x27ef066f3a3758ff8ee0cf5b86c7dbc0348f77e2
Solidity
Bridge
contract Bridge is IBridgeV1, Ownable { using SafeMath for uint256; // token for the bridge address public token; // List of TXs from the other chain that were processed mapping (bytes32 => bool) txHashes; // Current Fee Rate uint public fee = 5 * 1e18; constructor(address _tokenAddress) { token = _tokenAddress; } /** * @dev Initiates a token transfer from the given ledger to another Ethereum-compliant ledger. * @param amount The amount of tokens getting locked and swapped from the ledger * @param swapInAddress The address (on another ledger) to which the tokens are swapped */ function SwapOut(uint256 amount, address swapInAddress) external override returns (bool) { require(swapInAddress != address(0), "Bridge: swapInAddress"); require(amount > 0, "Bridge: amount"); require( IERC20(token).transferFrom(msg.sender, address(this), amount), "Bridge: transfer" ); emit LogSwapOut(msg.sender, swapInAddress, amount); return true; } /** * @dev Initiates a token transfer from the given ledger to another Ethereum-compliant ledger. * @param txHash Transaction hash on the ledger where the swap has beed initiated. * @param to The address to which the tokens are swapped * @param amount The amount of tokens released */ function SwapIn( bytes32 txHash, address to, uint256 amount ) external override onlyOwner returns (bool) { require (txHash != bytes32(0), "Bridge: invalid tx"); require (to != address(0), "Bridge: invalid addr"); require (txHashes[txHash] == false, "Bridge: dup tx"); txHashes[txHash] = true; require( IERC20(token).transfer(to, amount.sub(fee, "Bridge: invalid amount")), // automatically checks for amount > fee otherwise throw safemath "Bridge: transfer" ); emit LogSwapIn(txHash, to, amount.sub(fee), fee); return true; } /** * @dev Initiates a withdrawal transfer from the bridge contract to an address. Only call-able by the owner * @param to The address to which the tokens are swapped * @param amount The amount of tokens released */ function withdraw(address to, uint256 amount) external onlyOwner { IERC20(token).transfer(to, amount); } /** * @dev Update the fee on the current chain. Only call-able by the owner * @param newFee uint - the new fee that applies to the current side bridge */ function updateFee(uint newFee) external onlyOwner { uint oldFee = fee; fee = newFee; emit LogFeeUpdate(oldFee, newFee); } /** * @dev Add Liquidity to the Bridge contract * @param amount uint256 - the amount added to the liquidity in the bridge */ function addLiquidity(uint256 amount) external { IERC20(token).transferFrom(msg.sender, address(this), amount); emit LogLiquidityAdded(msg.sender, amount); } }
withdraw
function withdraw(address to, uint256 amount) external onlyOwner { IERC20(token).transfer(to, amount); }
/** * @dev Initiates a withdrawal transfer from the bridge contract to an address. Only call-able by the owner * @param to The address to which the tokens are swapped * @param amount The amount of tokens released */
NatSpecMultiLine
v0.8.0+commit.c7dfd78e
{ "func_code_index": [ 2332, 2452 ] }
58,759
Bridge
contracts/Bridge.sol
0x27ef066f3a3758ff8ee0cf5b86c7dbc0348f77e2
Solidity
Bridge
contract Bridge is IBridgeV1, Ownable { using SafeMath for uint256; // token for the bridge address public token; // List of TXs from the other chain that were processed mapping (bytes32 => bool) txHashes; // Current Fee Rate uint public fee = 5 * 1e18; constructor(address _tokenAddress) { token = _tokenAddress; } /** * @dev Initiates a token transfer from the given ledger to another Ethereum-compliant ledger. * @param amount The amount of tokens getting locked and swapped from the ledger * @param swapInAddress The address (on another ledger) to which the tokens are swapped */ function SwapOut(uint256 amount, address swapInAddress) external override returns (bool) { require(swapInAddress != address(0), "Bridge: swapInAddress"); require(amount > 0, "Bridge: amount"); require( IERC20(token).transferFrom(msg.sender, address(this), amount), "Bridge: transfer" ); emit LogSwapOut(msg.sender, swapInAddress, amount); return true; } /** * @dev Initiates a token transfer from the given ledger to another Ethereum-compliant ledger. * @param txHash Transaction hash on the ledger where the swap has beed initiated. * @param to The address to which the tokens are swapped * @param amount The amount of tokens released */ function SwapIn( bytes32 txHash, address to, uint256 amount ) external override onlyOwner returns (bool) { require (txHash != bytes32(0), "Bridge: invalid tx"); require (to != address(0), "Bridge: invalid addr"); require (txHashes[txHash] == false, "Bridge: dup tx"); txHashes[txHash] = true; require( IERC20(token).transfer(to, amount.sub(fee, "Bridge: invalid amount")), // automatically checks for amount > fee otherwise throw safemath "Bridge: transfer" ); emit LogSwapIn(txHash, to, amount.sub(fee), fee); return true; } /** * @dev Initiates a withdrawal transfer from the bridge contract to an address. Only call-able by the owner * @param to The address to which the tokens are swapped * @param amount The amount of tokens released */ function withdraw(address to, uint256 amount) external onlyOwner { IERC20(token).transfer(to, amount); } /** * @dev Update the fee on the current chain. Only call-able by the owner * @param newFee uint - the new fee that applies to the current side bridge */ function updateFee(uint newFee) external onlyOwner { uint oldFee = fee; fee = newFee; emit LogFeeUpdate(oldFee, newFee); } /** * @dev Add Liquidity to the Bridge contract * @param amount uint256 - the amount added to the liquidity in the bridge */ function addLiquidity(uint256 amount) external { IERC20(token).transferFrom(msg.sender, address(this), amount); emit LogLiquidityAdded(msg.sender, amount); } }
updateFee
function updateFee(uint newFee) external onlyOwner { uint oldFee = fee; fee = newFee; emit LogFeeUpdate(oldFee, newFee); }
/** * @dev Update the fee on the current chain. Only call-able by the owner * @param newFee uint - the new fee that applies to the current side bridge */
NatSpecMultiLine
v0.8.0+commit.c7dfd78e
{ "func_code_index": [ 2627, 2781 ] }
58,760