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
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
MuskFinance | MuskFinance.sol | 0x2e843a93998935022e52b6b94877dd1660467f74 | Solidity | Address | library Address {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*/
function isContract(address account) internal view returns (bool) {
// According to EIP-1052, 0x0 is the value returned for not-yet created accounts
// and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned
// for accounts without code, i.e. `keccak256('')`
bytes32 codehash;
bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470;
// solhint-disable-next-line no-inline-assembly
assembly { codehash := extcodehash(account) }
return (codehash != accountHash && codehash != 0x0);
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
// solhint-disable-next-line avoid-low-level-calls, avoid-call-value
(bool success, ) = recipient.call{ value: amount }("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain`call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {
return _functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
return _functionCallWithValue(target, data, value, errorMessage);
}
function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) {
require(isContract(target), "Address: call to non-contract");
// solhint-disable-next-line avoid-low-level-calls
(bool success, bytes memory returndata) = target.call{ value: weiValue }(data);
if (success) {
return returndata;
} else {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
// solhint-disable-next-line no-inline-assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
} | sendValue | function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
// solhint-disable-next-line avoid-low-level-calls, avoid-call-value
(bool success, ) = recipient.call{ value: amount }("");
require(success, "Address: unable to send value, recipient may have reverted");
}
| /**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/ | NatSpecMultiLine | v0.6.12+commit.27d51765 | MIT | ipfs://6255a7e7511730f9230d0fc910a1aba6e96a6dd74abb3683f87858ee265769f9 | {
"func_code_index": [
2158,
2560
]
} | 3,500 |
||
MuskFinance | MuskFinance.sol | 0x2e843a93998935022e52b6b94877dd1660467f74 | Solidity | Address | library Address {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*/
function isContract(address account) internal view returns (bool) {
// According to EIP-1052, 0x0 is the value returned for not-yet created accounts
// and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned
// for accounts without code, i.e. `keccak256('')`
bytes32 codehash;
bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470;
// solhint-disable-next-line no-inline-assembly
assembly { codehash := extcodehash(account) }
return (codehash != accountHash && codehash != 0x0);
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
// solhint-disable-next-line avoid-low-level-calls, avoid-call-value
(bool success, ) = recipient.call{ value: amount }("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain`call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {
return _functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
return _functionCallWithValue(target, data, value, errorMessage);
}
function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) {
require(isContract(target), "Address: call to non-contract");
// solhint-disable-next-line avoid-low-level-calls
(bool success, bytes memory returndata) = target.call{ value: weiValue }(data);
if (success) {
return returndata;
} else {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
// solhint-disable-next-line no-inline-assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
} | functionCall | function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, "Address: low-level call failed");
}
| /**
* @dev Performs a Solidity function call using a low level `call`. A
* plain`call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/ | NatSpecMultiLine | v0.6.12+commit.27d51765 | MIT | ipfs://6255a7e7511730f9230d0fc910a1aba6e96a6dd74abb3683f87858ee265769f9 | {
"func_code_index": [
3314,
3492
]
} | 3,501 |
||
MuskFinance | MuskFinance.sol | 0x2e843a93998935022e52b6b94877dd1660467f74 | Solidity | Address | library Address {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*/
function isContract(address account) internal view returns (bool) {
// According to EIP-1052, 0x0 is the value returned for not-yet created accounts
// and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned
// for accounts without code, i.e. `keccak256('')`
bytes32 codehash;
bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470;
// solhint-disable-next-line no-inline-assembly
assembly { codehash := extcodehash(account) }
return (codehash != accountHash && codehash != 0x0);
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
// solhint-disable-next-line avoid-low-level-calls, avoid-call-value
(bool success, ) = recipient.call{ value: amount }("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain`call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {
return _functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
return _functionCallWithValue(target, data, value, errorMessage);
}
function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) {
require(isContract(target), "Address: call to non-contract");
// solhint-disable-next-line avoid-low-level-calls
(bool success, bytes memory returndata) = target.call{ value: weiValue }(data);
if (success) {
return returndata;
} else {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
// solhint-disable-next-line no-inline-assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
} | functionCall | function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {
return _functionCallWithValue(target, data, 0, errorMessage);
}
| /**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/ | NatSpecMultiLine | v0.6.12+commit.27d51765 | MIT | ipfs://6255a7e7511730f9230d0fc910a1aba6e96a6dd74abb3683f87858ee265769f9 | {
"func_code_index": [
3715,
3916
]
} | 3,502 |
||
MuskFinance | MuskFinance.sol | 0x2e843a93998935022e52b6b94877dd1660467f74 | Solidity | Address | library Address {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*/
function isContract(address account) internal view returns (bool) {
// According to EIP-1052, 0x0 is the value returned for not-yet created accounts
// and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned
// for accounts without code, i.e. `keccak256('')`
bytes32 codehash;
bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470;
// solhint-disable-next-line no-inline-assembly
assembly { codehash := extcodehash(account) }
return (codehash != accountHash && codehash != 0x0);
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
// solhint-disable-next-line avoid-low-level-calls, avoid-call-value
(bool success, ) = recipient.call{ value: amount }("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain`call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {
return _functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
return _functionCallWithValue(target, data, value, errorMessage);
}
function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) {
require(isContract(target), "Address: call to non-contract");
// solhint-disable-next-line avoid-low-level-calls
(bool success, bytes memory returndata) = target.call{ value: weiValue }(data);
if (success) {
return returndata;
} else {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
// solhint-disable-next-line no-inline-assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
} | functionCallWithValue | function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
| /**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/ | NatSpecMultiLine | v0.6.12+commit.27d51765 | MIT | ipfs://6255a7e7511730f9230d0fc910a1aba6e96a6dd74abb3683f87858ee265769f9 | {
"func_code_index": [
4284,
4515
]
} | 3,503 |
||
MuskFinance | MuskFinance.sol | 0x2e843a93998935022e52b6b94877dd1660467f74 | Solidity | Address | library Address {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*/
function isContract(address account) internal view returns (bool) {
// According to EIP-1052, 0x0 is the value returned for not-yet created accounts
// and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned
// for accounts without code, i.e. `keccak256('')`
bytes32 codehash;
bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470;
// solhint-disable-next-line no-inline-assembly
assembly { codehash := extcodehash(account) }
return (codehash != accountHash && codehash != 0x0);
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
// solhint-disable-next-line avoid-low-level-calls, avoid-call-value
(bool success, ) = recipient.call{ value: amount }("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain`call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {
return _functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
return _functionCallWithValue(target, data, value, errorMessage);
}
function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) {
require(isContract(target), "Address: call to non-contract");
// solhint-disable-next-line avoid-low-level-calls
(bool success, bytes memory returndata) = target.call{ value: weiValue }(data);
if (success) {
return returndata;
} else {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
// solhint-disable-next-line no-inline-assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
} | functionCallWithValue | function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
return _functionCallWithValue(target, data, value, errorMessage);
}
| /**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/ | NatSpecMultiLine | v0.6.12+commit.27d51765 | MIT | ipfs://6255a7e7511730f9230d0fc910a1aba6e96a6dd74abb3683f87858ee265769f9 | {
"func_code_index": [
4764,
5085
]
} | 3,504 |
||
MuskFinance | MuskFinance.sol | 0x2e843a93998935022e52b6b94877dd1660467f74 | Solidity | Ownable | contract Ownable is Context {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/
constructor () internal {
address msgSender = _msgSender();
_owner = msgSender;
emit OwnershipTransferred(address(0), msgSender);
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view returns (address) {
return _owner;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(_owner == _msgSender(), "Ownable: caller is not the owner");
_;
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions anymore. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby removing any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
emit OwnershipTransferred(_owner, address(0));
_owner = address(0);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
emit OwnershipTransferred(_owner, newOwner);
_owner = newOwner;
}
} | owner | function owner() public view returns (address) {
return _owner;
}
| /**
* @dev Returns the address of the current owner.
*/ | NatSpecMultiLine | v0.6.12+commit.27d51765 | MIT | ipfs://6255a7e7511730f9230d0fc910a1aba6e96a6dd74abb3683f87858ee265769f9 | {
"func_code_index": [
493,
577
]
} | 3,505 |
||
MuskFinance | MuskFinance.sol | 0x2e843a93998935022e52b6b94877dd1660467f74 | Solidity | Ownable | contract Ownable is Context {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/
constructor () internal {
address msgSender = _msgSender();
_owner = msgSender;
emit OwnershipTransferred(address(0), msgSender);
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view returns (address) {
return _owner;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(_owner == _msgSender(), "Ownable: caller is not the owner");
_;
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions anymore. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby removing any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
emit OwnershipTransferred(_owner, address(0));
_owner = address(0);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
emit OwnershipTransferred(_owner, newOwner);
_owner = newOwner;
}
} | renounceOwnership | function renounceOwnership() public virtual onlyOwner {
emit OwnershipTransferred(_owner, address(0));
_owner = address(0);
}
| /**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions anymore. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby removing any functionality that is only available to the owner.
*/ | NatSpecMultiLine | v0.6.12+commit.27d51765 | MIT | ipfs://6255a7e7511730f9230d0fc910a1aba6e96a6dd74abb3683f87858ee265769f9 | {
"func_code_index": [
1131,
1284
]
} | 3,506 |
||
MuskFinance | MuskFinance.sol | 0x2e843a93998935022e52b6b94877dd1660467f74 | Solidity | Ownable | contract Ownable is Context {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/
constructor () internal {
address msgSender = _msgSender();
_owner = msgSender;
emit OwnershipTransferred(address(0), msgSender);
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view returns (address) {
return _owner;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(_owner == _msgSender(), "Ownable: caller is not the owner");
_;
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions anymore. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby removing any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
emit OwnershipTransferred(_owner, address(0));
_owner = address(0);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
emit OwnershipTransferred(_owner, newOwner);
_owner = newOwner;
}
} | transferOwnership | function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
emit OwnershipTransferred(_owner, newOwner);
_owner = newOwner;
}
| /**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/ | NatSpecMultiLine | v0.6.12+commit.27d51765 | MIT | ipfs://6255a7e7511730f9230d0fc910a1aba6e96a6dd74abb3683f87858ee265769f9 | {
"func_code_index": [
1432,
1681
]
} | 3,507 |
||
MultiSigWallet | MultiSigWallet.sol | 0x615ed6779507f223d04722d43ccc0cd871964e2a | Solidity | ERC20Interface | contract ERC20Interface {
// Get the total token supply
function totalSupply() public constant returns (uint256 _totalSupply);
// Get the account balance of another account with address _owner
function balanceOf(address _owner) public constant returns (uint256 balance);
// Send _value amount of tokens to address _to
function transfer(address _to, uint256 _value) public returns (bool success);
// transfer _value amount of token approved by address _from
function transferFrom(address _from, address _to, uint256 _value) public returns (bool success);
// approve an address with _value amount of tokens
function approve(address _spender, uint256 _value) public returns (bool success);
// get remaining token approved by _owner to _spender
function allowance(address _owner, address _spender) public constant returns (uint256 remaining);
// Triggered when tokens are transferred.
event Transfer(address indexed _from, address indexed _to, uint256 _value);
// Triggered whenever approve(address _spender, uint256 _value) is called.
event Approval(address indexed _owner, address indexed _spender, uint256 _value);
} | // ----------------------------------------------------------------------------------------------
// Gifto Token by Gifto Limited.
// An ERC20 standard
//
// author: Gifto Team
// Contact: [email protected] | LineComment | totalSupply | function totalSupply() public constant returns (uint256 _totalSupply);
| // Get the total token supply | LineComment | v0.4.18+commit.9cf6e910 | bzzr://891e8485538f16f2fa5b9af11f8c795bc62d51fb6455063a6ee3652fa7680f20 | {
"func_code_index": [
62,
137
]
} | 3,508 |
|
MultiSigWallet | MultiSigWallet.sol | 0x615ed6779507f223d04722d43ccc0cd871964e2a | Solidity | ERC20Interface | contract ERC20Interface {
// Get the total token supply
function totalSupply() public constant returns (uint256 _totalSupply);
// Get the account balance of another account with address _owner
function balanceOf(address _owner) public constant returns (uint256 balance);
// Send _value amount of tokens to address _to
function transfer(address _to, uint256 _value) public returns (bool success);
// transfer _value amount of token approved by address _from
function transferFrom(address _from, address _to, uint256 _value) public returns (bool success);
// approve an address with _value amount of tokens
function approve(address _spender, uint256 _value) public returns (bool success);
// get remaining token approved by _owner to _spender
function allowance(address _owner, address _spender) public constant returns (uint256 remaining);
// Triggered when tokens are transferred.
event Transfer(address indexed _from, address indexed _to, uint256 _value);
// Triggered whenever approve(address _spender, uint256 _value) is called.
event Approval(address indexed _owner, address indexed _spender, uint256 _value);
} | // ----------------------------------------------------------------------------------------------
// Gifto Token by Gifto Limited.
// An ERC20 standard
//
// author: Gifto Team
// Contact: [email protected] | LineComment | balanceOf | function balanceOf(address _owner) public constant returns (uint256 balance);
| // Get the account balance of another account with address _owner | LineComment | v0.4.18+commit.9cf6e910 | bzzr://891e8485538f16f2fa5b9af11f8c795bc62d51fb6455063a6ee3652fa7680f20 | {
"func_code_index": [
212,
294
]
} | 3,509 |
|
MultiSigWallet | MultiSigWallet.sol | 0x615ed6779507f223d04722d43ccc0cd871964e2a | Solidity | ERC20Interface | contract ERC20Interface {
// Get the total token supply
function totalSupply() public constant returns (uint256 _totalSupply);
// Get the account balance of another account with address _owner
function balanceOf(address _owner) public constant returns (uint256 balance);
// Send _value amount of tokens to address _to
function transfer(address _to, uint256 _value) public returns (bool success);
// transfer _value amount of token approved by address _from
function transferFrom(address _from, address _to, uint256 _value) public returns (bool success);
// approve an address with _value amount of tokens
function approve(address _spender, uint256 _value) public returns (bool success);
// get remaining token approved by _owner to _spender
function allowance(address _owner, address _spender) public constant returns (uint256 remaining);
// Triggered when tokens are transferred.
event Transfer(address indexed _from, address indexed _to, uint256 _value);
// Triggered whenever approve(address _spender, uint256 _value) is called.
event Approval(address indexed _owner, address indexed _spender, uint256 _value);
} | // ----------------------------------------------------------------------------------------------
// Gifto Token by Gifto Limited.
// An ERC20 standard
//
// author: Gifto Team
// Contact: [email protected] | LineComment | transfer | function transfer(address _to, uint256 _value) public returns (bool success);
| // Send _value amount of tokens to address _to | LineComment | v0.4.18+commit.9cf6e910 | bzzr://891e8485538f16f2fa5b9af11f8c795bc62d51fb6455063a6ee3652fa7680f20 | {
"func_code_index": [
350,
432
]
} | 3,510 |
|
MultiSigWallet | MultiSigWallet.sol | 0x615ed6779507f223d04722d43ccc0cd871964e2a | Solidity | ERC20Interface | contract ERC20Interface {
// Get the total token supply
function totalSupply() public constant returns (uint256 _totalSupply);
// Get the account balance of another account with address _owner
function balanceOf(address _owner) public constant returns (uint256 balance);
// Send _value amount of tokens to address _to
function transfer(address _to, uint256 _value) public returns (bool success);
// transfer _value amount of token approved by address _from
function transferFrom(address _from, address _to, uint256 _value) public returns (bool success);
// approve an address with _value amount of tokens
function approve(address _spender, uint256 _value) public returns (bool success);
// get remaining token approved by _owner to _spender
function allowance(address _owner, address _spender) public constant returns (uint256 remaining);
// Triggered when tokens are transferred.
event Transfer(address indexed _from, address indexed _to, uint256 _value);
// Triggered whenever approve(address _spender, uint256 _value) is called.
event Approval(address indexed _owner, address indexed _spender, uint256 _value);
} | // ----------------------------------------------------------------------------------------------
// Gifto Token by Gifto Limited.
// An ERC20 standard
//
// author: Gifto Team
// Contact: [email protected] | LineComment | transferFrom | function transferFrom(address _from, address _to, uint256 _value) public returns (bool success);
| // transfer _value amount of token approved by address _from | LineComment | v0.4.18+commit.9cf6e910 | bzzr://891e8485538f16f2fa5b9af11f8c795bc62d51fb6455063a6ee3652fa7680f20 | {
"func_code_index": [
505,
606
]
} | 3,511 |
|
MultiSigWallet | MultiSigWallet.sol | 0x615ed6779507f223d04722d43ccc0cd871964e2a | Solidity | ERC20Interface | contract ERC20Interface {
// Get the total token supply
function totalSupply() public constant returns (uint256 _totalSupply);
// Get the account balance of another account with address _owner
function balanceOf(address _owner) public constant returns (uint256 balance);
// Send _value amount of tokens to address _to
function transfer(address _to, uint256 _value) public returns (bool success);
// transfer _value amount of token approved by address _from
function transferFrom(address _from, address _to, uint256 _value) public returns (bool success);
// approve an address with _value amount of tokens
function approve(address _spender, uint256 _value) public returns (bool success);
// get remaining token approved by _owner to _spender
function allowance(address _owner, address _spender) public constant returns (uint256 remaining);
// Triggered when tokens are transferred.
event Transfer(address indexed _from, address indexed _to, uint256 _value);
// Triggered whenever approve(address _spender, uint256 _value) is called.
event Approval(address indexed _owner, address indexed _spender, uint256 _value);
} | // ----------------------------------------------------------------------------------------------
// Gifto Token by Gifto Limited.
// An ERC20 standard
//
// author: Gifto Team
// Contact: [email protected] | LineComment | approve | function approve(address _spender, uint256 _value) public returns (bool success);
| // approve an address with _value amount of tokens | LineComment | v0.4.18+commit.9cf6e910 | bzzr://891e8485538f16f2fa5b9af11f8c795bc62d51fb6455063a6ee3652fa7680f20 | {
"func_code_index": [
665,
751
]
} | 3,512 |
|
MultiSigWallet | MultiSigWallet.sol | 0x615ed6779507f223d04722d43ccc0cd871964e2a | Solidity | ERC20Interface | contract ERC20Interface {
// Get the total token supply
function totalSupply() public constant returns (uint256 _totalSupply);
// Get the account balance of another account with address _owner
function balanceOf(address _owner) public constant returns (uint256 balance);
// Send _value amount of tokens to address _to
function transfer(address _to, uint256 _value) public returns (bool success);
// transfer _value amount of token approved by address _from
function transferFrom(address _from, address _to, uint256 _value) public returns (bool success);
// approve an address with _value amount of tokens
function approve(address _spender, uint256 _value) public returns (bool success);
// get remaining token approved by _owner to _spender
function allowance(address _owner, address _spender) public constant returns (uint256 remaining);
// Triggered when tokens are transferred.
event Transfer(address indexed _from, address indexed _to, uint256 _value);
// Triggered whenever approve(address _spender, uint256 _value) is called.
event Approval(address indexed _owner, address indexed _spender, uint256 _value);
} | // ----------------------------------------------------------------------------------------------
// Gifto Token by Gifto Limited.
// An ERC20 standard
//
// author: Gifto Team
// Contact: [email protected] | LineComment | allowance | function allowance(address _owner, address _spender) public constant returns (uint256 remaining);
| // get remaining token approved by _owner to _spender | LineComment | v0.4.18+commit.9cf6e910 | bzzr://891e8485538f16f2fa5b9af11f8c795bc62d51fb6455063a6ee3652fa7680f20 | {
"func_code_index": [
813,
915
]
} | 3,513 |
|
MultiSigWallet | MultiSigWallet.sol | 0x615ed6779507f223d04722d43ccc0cd871964e2a | Solidity | Gifto | contract Gifto is ERC20Interface {
uint256 public constant decimals = 5;
string public constant symbol = "GTO";
string public constant name = "Gifto";
bool public _selling = true;//initial selling
uint256 public _totalSupply = 10 ** 14; // total supply is 10^14 unit, equivalent to 10^9 Gifto
uint256 public _originalBuyPrice = 43 * 10**7; // original buy 1ETH = 4300 Gifto = 43 * 10**7 unit
// Owner of this contract
address public owner;
// Balances Gifto for each account
mapping(address => uint256) private balances;
// Owner of account approves the transfer of an amount to another account
mapping(address => mapping (address => uint256)) private allowed;
// List of approved investors
mapping(address => bool) private approvedInvestorList;
// deposit
mapping(address => uint256) private deposit;
// icoPercent
uint256 public _icoPercent = 10;
// _icoSupply is the avalable unit. Initially, it is _totalSupply
uint256 public _icoSupply = _totalSupply * _icoPercent / 100;
// minimum buy 0.3 ETH
uint256 public _minimumBuy = 3 * 10 ** 17;
// maximum buy 25 ETH
uint256 public _maximumBuy = 25 * 10 ** 18;
// totalTokenSold
uint256 public totalTokenSold = 0;
// tradable
bool public tradable = false;
/**
* Functions with this modifier can only be executed by the owner
*/
modifier onlyOwner() {
require(msg.sender == owner);
_;
}
/**
* Functions with this modifier check on sale status
* Only allow sale if _selling is on
*/
modifier onSale() {
require(_selling);
_;
}
/**
* Functions with this modifier check the validity of address is investor
*/
modifier validInvestor() {
require(approvedInvestorList[msg.sender]);
_;
}
/**
* Functions with this modifier check the validity of msg value
* value must greater than equal minimumBuyPrice
* total deposit must less than equal maximumBuyPrice
*/
modifier validValue(){
// require value >= _minimumBuy AND total deposit of msg.sender <= maximumBuyPrice
require ( (msg.value >= _minimumBuy) &&
( (deposit[msg.sender] + msg.value) <= _maximumBuy) );
_;
}
/**
*
*/
modifier isTradable(){
require(tradable == true || msg.sender == owner);
_;
}
/// @dev Fallback function allows to buy ether.
function()
public
payable {
buyGifto();
}
/// @dev buy function allows to buy ether. for using optional data
function buyGifto()
public
payable
onSale
validValue
validInvestor {
uint256 requestedUnits = (msg.value * _originalBuyPrice) / 10**18;
require(balances[owner] >= requestedUnits);
// prepare transfer data
balances[owner] -= requestedUnits;
balances[msg.sender] += requestedUnits;
// increase total deposit amount
deposit[msg.sender] += msg.value;
// check total and auto turnOffSale
totalTokenSold += requestedUnits;
if (totalTokenSold >= _icoSupply){
_selling = false;
}
// submit transfer
Transfer(owner, msg.sender, requestedUnits);
owner.transfer(msg.value);
}
/// @dev Constructor
function Gifto()
public {
owner = msg.sender;
setBuyPrice(_originalBuyPrice);
balances[owner] = _totalSupply;
Transfer(0x0, owner, _totalSupply);
}
/// @dev Gets totalSupply
/// @return Total supply
function totalSupply()
public
constant
returns (uint256) {
return _totalSupply;
}
/// @dev Enables sale
function turnOnSale() onlyOwner
public {
_selling = true;
}
/// @dev Disables sale
function turnOffSale() onlyOwner
public {
_selling = false;
}
function turnOnTradable()
public
onlyOwner{
tradable = true;
}
/// @dev set new icoPercent
/// @param newIcoPercent new value of icoPercent
function setIcoPercent(uint256 newIcoPercent)
public
onlyOwner {
_icoPercent = newIcoPercent;
_icoSupply = _totalSupply * _icoPercent / 100;
}
/// @dev set new _maximumBuy
/// @param newMaximumBuy new value of _maximumBuy
function setMaximumBuy(uint256 newMaximumBuy)
public
onlyOwner {
_maximumBuy = newMaximumBuy;
}
/// @dev Updates buy price (owner ONLY)
/// @param newBuyPrice New buy price (in unit)
function setBuyPrice(uint256 newBuyPrice)
onlyOwner
public {
require(newBuyPrice>0);
_originalBuyPrice = newBuyPrice; // 3000 Gifto = 3000 00000 unit
// control _maximumBuy_USD = 10,000 USD, Gifto price is 0.1USD
// maximumBuy_Gifto = 100,000 Gifto = 100,000,00000 unit
// 3000 Gifto = 1ETH => maximumETH = 100,000,00000 / _originalBuyPrice
// 100,000,00000/3000 0000 ~ 33ETH => change to wei
_maximumBuy = 10**18 * 10000000000 /_originalBuyPrice;
}
/// @dev Gets account's balance
/// @param _addr Address of the account
/// @return Account balance
function balanceOf(address _addr)
public
constant
returns (uint256) {
return balances[_addr];
}
/// @dev check address is approved investor
/// @param _addr address
function isApprovedInvestor(address _addr)
public
constant
returns (bool) {
return approvedInvestorList[_addr];
}
/// @dev get ETH deposit
/// @param _addr address get deposit
/// @return amount deposit of an buyer
function getDeposit(address _addr)
public
constant
returns(uint256){
return deposit[_addr];
}
/// @dev Adds list of new investors to the investors list and approve all
/// @param newInvestorList Array of new investors addresses to be added
function addInvestorList(address[] newInvestorList)
onlyOwner
public {
for (uint256 i = 0; i < newInvestorList.length; i++){
approvedInvestorList[newInvestorList[i]] = true;
}
}
/// @dev Removes list of investors from list
/// @param investorList Array of addresses of investors to be removed
function removeInvestorList(address[] investorList)
onlyOwner
public {
for (uint256 i = 0; i < investorList.length; i++){
approvedInvestorList[investorList[i]] = false;
}
}
/// @dev Transfers the balance from msg.sender to an account
/// @param _to Recipient address
/// @param _amount Transfered amount in unit
/// @return Transfer status
function transfer(address _to, uint256 _amount)
public
isTradable
returns (bool) {
// if sender's balance has enough unit and amount >= 0,
// and the sum is not overflow,
// then do transfer
if ( (balances[msg.sender] >= _amount) &&
(_amount >= 0) &&
(balances[_to] + _amount > balances[_to]) ) {
balances[msg.sender] -= _amount;
balances[_to] += _amount;
Transfer(msg.sender, _to, _amount);
return true;
} else {
return false;
}
}
// Send _value amount of tokens from address _from to address _to
// The transferFrom method is used for a withdraw workflow, allowing contracts to send
// tokens on your behalf, for example to "deposit" to a contract address and/or to charge
// fees in sub-currencies; the command should fail unless the _from account has
// deliberately authorized the sender of the message via some mechanism; we propose
// these standardized APIs for approval:
function transferFrom(
address _from,
address _to,
uint256 _amount
)
public
isTradable
returns (bool success) {
if (balances[_from] >= _amount
&& allowed[_from][msg.sender] >= _amount
&& _amount > 0
&& balances[_to] + _amount > balances[_to]) {
balances[_from] -= _amount;
allowed[_from][msg.sender] -= _amount;
balances[_to] += _amount;
Transfer(_from, _to, _amount);
return true;
} else {
return false;
}
}
// Allow _spender to withdraw from your account, multiple times, up to the _value amount.
// If this function is called again it overwrites the current allowance with _value.
function approve(address _spender, uint256 _amount)
public
isTradable
returns (bool success) {
allowed[msg.sender][_spender] = _amount;
Approval(msg.sender, _spender, _amount);
return true;
}
// get allowance
function allowance(address _owner, address _spender)
public
constant
returns (uint256 remaining) {
return allowed[_owner][_spender];
}
/// @dev Withdraws Ether in contract (Owner only)
/// @return Status of withdrawal
function withdraw() onlyOwner
public
returns (bool) {
return owner.send(this.balance);
}
} | function()
public
payable {
buyGifto();
}
| /// @dev Fallback function allows to buy ether. | NatSpecSingleLine | v0.4.18+commit.9cf6e910 | bzzr://891e8485538f16f2fa5b9af11f8c795bc62d51fb6455063a6ee3652fa7680f20 | {
"func_code_index": [
2639,
2717
]
} | 3,514 |
||||
MultiSigWallet | MultiSigWallet.sol | 0x615ed6779507f223d04722d43ccc0cd871964e2a | Solidity | Gifto | contract Gifto is ERC20Interface {
uint256 public constant decimals = 5;
string public constant symbol = "GTO";
string public constant name = "Gifto";
bool public _selling = true;//initial selling
uint256 public _totalSupply = 10 ** 14; // total supply is 10^14 unit, equivalent to 10^9 Gifto
uint256 public _originalBuyPrice = 43 * 10**7; // original buy 1ETH = 4300 Gifto = 43 * 10**7 unit
// Owner of this contract
address public owner;
// Balances Gifto for each account
mapping(address => uint256) private balances;
// Owner of account approves the transfer of an amount to another account
mapping(address => mapping (address => uint256)) private allowed;
// List of approved investors
mapping(address => bool) private approvedInvestorList;
// deposit
mapping(address => uint256) private deposit;
// icoPercent
uint256 public _icoPercent = 10;
// _icoSupply is the avalable unit. Initially, it is _totalSupply
uint256 public _icoSupply = _totalSupply * _icoPercent / 100;
// minimum buy 0.3 ETH
uint256 public _minimumBuy = 3 * 10 ** 17;
// maximum buy 25 ETH
uint256 public _maximumBuy = 25 * 10 ** 18;
// totalTokenSold
uint256 public totalTokenSold = 0;
// tradable
bool public tradable = false;
/**
* Functions with this modifier can only be executed by the owner
*/
modifier onlyOwner() {
require(msg.sender == owner);
_;
}
/**
* Functions with this modifier check on sale status
* Only allow sale if _selling is on
*/
modifier onSale() {
require(_selling);
_;
}
/**
* Functions with this modifier check the validity of address is investor
*/
modifier validInvestor() {
require(approvedInvestorList[msg.sender]);
_;
}
/**
* Functions with this modifier check the validity of msg value
* value must greater than equal minimumBuyPrice
* total deposit must less than equal maximumBuyPrice
*/
modifier validValue(){
// require value >= _minimumBuy AND total deposit of msg.sender <= maximumBuyPrice
require ( (msg.value >= _minimumBuy) &&
( (deposit[msg.sender] + msg.value) <= _maximumBuy) );
_;
}
/**
*
*/
modifier isTradable(){
require(tradable == true || msg.sender == owner);
_;
}
/// @dev Fallback function allows to buy ether.
function()
public
payable {
buyGifto();
}
/// @dev buy function allows to buy ether. for using optional data
function buyGifto()
public
payable
onSale
validValue
validInvestor {
uint256 requestedUnits = (msg.value * _originalBuyPrice) / 10**18;
require(balances[owner] >= requestedUnits);
// prepare transfer data
balances[owner] -= requestedUnits;
balances[msg.sender] += requestedUnits;
// increase total deposit amount
deposit[msg.sender] += msg.value;
// check total and auto turnOffSale
totalTokenSold += requestedUnits;
if (totalTokenSold >= _icoSupply){
_selling = false;
}
// submit transfer
Transfer(owner, msg.sender, requestedUnits);
owner.transfer(msg.value);
}
/// @dev Constructor
function Gifto()
public {
owner = msg.sender;
setBuyPrice(_originalBuyPrice);
balances[owner] = _totalSupply;
Transfer(0x0, owner, _totalSupply);
}
/// @dev Gets totalSupply
/// @return Total supply
function totalSupply()
public
constant
returns (uint256) {
return _totalSupply;
}
/// @dev Enables sale
function turnOnSale() onlyOwner
public {
_selling = true;
}
/// @dev Disables sale
function turnOffSale() onlyOwner
public {
_selling = false;
}
function turnOnTradable()
public
onlyOwner{
tradable = true;
}
/// @dev set new icoPercent
/// @param newIcoPercent new value of icoPercent
function setIcoPercent(uint256 newIcoPercent)
public
onlyOwner {
_icoPercent = newIcoPercent;
_icoSupply = _totalSupply * _icoPercent / 100;
}
/// @dev set new _maximumBuy
/// @param newMaximumBuy new value of _maximumBuy
function setMaximumBuy(uint256 newMaximumBuy)
public
onlyOwner {
_maximumBuy = newMaximumBuy;
}
/// @dev Updates buy price (owner ONLY)
/// @param newBuyPrice New buy price (in unit)
function setBuyPrice(uint256 newBuyPrice)
onlyOwner
public {
require(newBuyPrice>0);
_originalBuyPrice = newBuyPrice; // 3000 Gifto = 3000 00000 unit
// control _maximumBuy_USD = 10,000 USD, Gifto price is 0.1USD
// maximumBuy_Gifto = 100,000 Gifto = 100,000,00000 unit
// 3000 Gifto = 1ETH => maximumETH = 100,000,00000 / _originalBuyPrice
// 100,000,00000/3000 0000 ~ 33ETH => change to wei
_maximumBuy = 10**18 * 10000000000 /_originalBuyPrice;
}
/// @dev Gets account's balance
/// @param _addr Address of the account
/// @return Account balance
function balanceOf(address _addr)
public
constant
returns (uint256) {
return balances[_addr];
}
/// @dev check address is approved investor
/// @param _addr address
function isApprovedInvestor(address _addr)
public
constant
returns (bool) {
return approvedInvestorList[_addr];
}
/// @dev get ETH deposit
/// @param _addr address get deposit
/// @return amount deposit of an buyer
function getDeposit(address _addr)
public
constant
returns(uint256){
return deposit[_addr];
}
/// @dev Adds list of new investors to the investors list and approve all
/// @param newInvestorList Array of new investors addresses to be added
function addInvestorList(address[] newInvestorList)
onlyOwner
public {
for (uint256 i = 0; i < newInvestorList.length; i++){
approvedInvestorList[newInvestorList[i]] = true;
}
}
/// @dev Removes list of investors from list
/// @param investorList Array of addresses of investors to be removed
function removeInvestorList(address[] investorList)
onlyOwner
public {
for (uint256 i = 0; i < investorList.length; i++){
approvedInvestorList[investorList[i]] = false;
}
}
/// @dev Transfers the balance from msg.sender to an account
/// @param _to Recipient address
/// @param _amount Transfered amount in unit
/// @return Transfer status
function transfer(address _to, uint256 _amount)
public
isTradable
returns (bool) {
// if sender's balance has enough unit and amount >= 0,
// and the sum is not overflow,
// then do transfer
if ( (balances[msg.sender] >= _amount) &&
(_amount >= 0) &&
(balances[_to] + _amount > balances[_to]) ) {
balances[msg.sender] -= _amount;
balances[_to] += _amount;
Transfer(msg.sender, _to, _amount);
return true;
} else {
return false;
}
}
// Send _value amount of tokens from address _from to address _to
// The transferFrom method is used for a withdraw workflow, allowing contracts to send
// tokens on your behalf, for example to "deposit" to a contract address and/or to charge
// fees in sub-currencies; the command should fail unless the _from account has
// deliberately authorized the sender of the message via some mechanism; we propose
// these standardized APIs for approval:
function transferFrom(
address _from,
address _to,
uint256 _amount
)
public
isTradable
returns (bool success) {
if (balances[_from] >= _amount
&& allowed[_from][msg.sender] >= _amount
&& _amount > 0
&& balances[_to] + _amount > balances[_to]) {
balances[_from] -= _amount;
allowed[_from][msg.sender] -= _amount;
balances[_to] += _amount;
Transfer(_from, _to, _amount);
return true;
} else {
return false;
}
}
// Allow _spender to withdraw from your account, multiple times, up to the _value amount.
// If this function is called again it overwrites the current allowance with _value.
function approve(address _spender, uint256 _amount)
public
isTradable
returns (bool success) {
allowed[msg.sender][_spender] = _amount;
Approval(msg.sender, _spender, _amount);
return true;
}
// get allowance
function allowance(address _owner, address _spender)
public
constant
returns (uint256 remaining) {
return allowed[_owner][_spender];
}
/// @dev Withdraws Ether in contract (Owner only)
/// @return Status of withdrawal
function withdraw() onlyOwner
public
returns (bool) {
return owner.send(this.balance);
}
} | buyGifto | function buyGifto()
public
payable
onSale
validValue
validInvestor {
uint256 requestedUnits = (msg.value * _originalBuyPrice) / 10**18;
require(balances[owner] >= requestedUnits);
// prepare transfer data
balances[owner] -= requestedUnits;
balances[msg.sender] += requestedUnits;
// increase total deposit amount
deposit[msg.sender] += msg.value;
// check total and auto turnOffSale
totalTokenSold += requestedUnits;
if (totalTokenSold >= _icoSupply){
_selling = false;
}
// submit transfer
Transfer(owner, msg.sender, requestedUnits);
owner.transfer(msg.value);
}
| /// @dev buy function allows to buy ether. for using optional data | NatSpecSingleLine | v0.4.18+commit.9cf6e910 | bzzr://891e8485538f16f2fa5b9af11f8c795bc62d51fb6455063a6ee3652fa7680f20 | {
"func_code_index": [
2796,
3584
]
} | 3,515 |
|||
MultiSigWallet | MultiSigWallet.sol | 0x615ed6779507f223d04722d43ccc0cd871964e2a | Solidity | Gifto | contract Gifto is ERC20Interface {
uint256 public constant decimals = 5;
string public constant symbol = "GTO";
string public constant name = "Gifto";
bool public _selling = true;//initial selling
uint256 public _totalSupply = 10 ** 14; // total supply is 10^14 unit, equivalent to 10^9 Gifto
uint256 public _originalBuyPrice = 43 * 10**7; // original buy 1ETH = 4300 Gifto = 43 * 10**7 unit
// Owner of this contract
address public owner;
// Balances Gifto for each account
mapping(address => uint256) private balances;
// Owner of account approves the transfer of an amount to another account
mapping(address => mapping (address => uint256)) private allowed;
// List of approved investors
mapping(address => bool) private approvedInvestorList;
// deposit
mapping(address => uint256) private deposit;
// icoPercent
uint256 public _icoPercent = 10;
// _icoSupply is the avalable unit. Initially, it is _totalSupply
uint256 public _icoSupply = _totalSupply * _icoPercent / 100;
// minimum buy 0.3 ETH
uint256 public _minimumBuy = 3 * 10 ** 17;
// maximum buy 25 ETH
uint256 public _maximumBuy = 25 * 10 ** 18;
// totalTokenSold
uint256 public totalTokenSold = 0;
// tradable
bool public tradable = false;
/**
* Functions with this modifier can only be executed by the owner
*/
modifier onlyOwner() {
require(msg.sender == owner);
_;
}
/**
* Functions with this modifier check on sale status
* Only allow sale if _selling is on
*/
modifier onSale() {
require(_selling);
_;
}
/**
* Functions with this modifier check the validity of address is investor
*/
modifier validInvestor() {
require(approvedInvestorList[msg.sender]);
_;
}
/**
* Functions with this modifier check the validity of msg value
* value must greater than equal minimumBuyPrice
* total deposit must less than equal maximumBuyPrice
*/
modifier validValue(){
// require value >= _minimumBuy AND total deposit of msg.sender <= maximumBuyPrice
require ( (msg.value >= _minimumBuy) &&
( (deposit[msg.sender] + msg.value) <= _maximumBuy) );
_;
}
/**
*
*/
modifier isTradable(){
require(tradable == true || msg.sender == owner);
_;
}
/// @dev Fallback function allows to buy ether.
function()
public
payable {
buyGifto();
}
/// @dev buy function allows to buy ether. for using optional data
function buyGifto()
public
payable
onSale
validValue
validInvestor {
uint256 requestedUnits = (msg.value * _originalBuyPrice) / 10**18;
require(balances[owner] >= requestedUnits);
// prepare transfer data
balances[owner] -= requestedUnits;
balances[msg.sender] += requestedUnits;
// increase total deposit amount
deposit[msg.sender] += msg.value;
// check total and auto turnOffSale
totalTokenSold += requestedUnits;
if (totalTokenSold >= _icoSupply){
_selling = false;
}
// submit transfer
Transfer(owner, msg.sender, requestedUnits);
owner.transfer(msg.value);
}
/// @dev Constructor
function Gifto()
public {
owner = msg.sender;
setBuyPrice(_originalBuyPrice);
balances[owner] = _totalSupply;
Transfer(0x0, owner, _totalSupply);
}
/// @dev Gets totalSupply
/// @return Total supply
function totalSupply()
public
constant
returns (uint256) {
return _totalSupply;
}
/// @dev Enables sale
function turnOnSale() onlyOwner
public {
_selling = true;
}
/// @dev Disables sale
function turnOffSale() onlyOwner
public {
_selling = false;
}
function turnOnTradable()
public
onlyOwner{
tradable = true;
}
/// @dev set new icoPercent
/// @param newIcoPercent new value of icoPercent
function setIcoPercent(uint256 newIcoPercent)
public
onlyOwner {
_icoPercent = newIcoPercent;
_icoSupply = _totalSupply * _icoPercent / 100;
}
/// @dev set new _maximumBuy
/// @param newMaximumBuy new value of _maximumBuy
function setMaximumBuy(uint256 newMaximumBuy)
public
onlyOwner {
_maximumBuy = newMaximumBuy;
}
/// @dev Updates buy price (owner ONLY)
/// @param newBuyPrice New buy price (in unit)
function setBuyPrice(uint256 newBuyPrice)
onlyOwner
public {
require(newBuyPrice>0);
_originalBuyPrice = newBuyPrice; // 3000 Gifto = 3000 00000 unit
// control _maximumBuy_USD = 10,000 USD, Gifto price is 0.1USD
// maximumBuy_Gifto = 100,000 Gifto = 100,000,00000 unit
// 3000 Gifto = 1ETH => maximumETH = 100,000,00000 / _originalBuyPrice
// 100,000,00000/3000 0000 ~ 33ETH => change to wei
_maximumBuy = 10**18 * 10000000000 /_originalBuyPrice;
}
/// @dev Gets account's balance
/// @param _addr Address of the account
/// @return Account balance
function balanceOf(address _addr)
public
constant
returns (uint256) {
return balances[_addr];
}
/// @dev check address is approved investor
/// @param _addr address
function isApprovedInvestor(address _addr)
public
constant
returns (bool) {
return approvedInvestorList[_addr];
}
/// @dev get ETH deposit
/// @param _addr address get deposit
/// @return amount deposit of an buyer
function getDeposit(address _addr)
public
constant
returns(uint256){
return deposit[_addr];
}
/// @dev Adds list of new investors to the investors list and approve all
/// @param newInvestorList Array of new investors addresses to be added
function addInvestorList(address[] newInvestorList)
onlyOwner
public {
for (uint256 i = 0; i < newInvestorList.length; i++){
approvedInvestorList[newInvestorList[i]] = true;
}
}
/// @dev Removes list of investors from list
/// @param investorList Array of addresses of investors to be removed
function removeInvestorList(address[] investorList)
onlyOwner
public {
for (uint256 i = 0; i < investorList.length; i++){
approvedInvestorList[investorList[i]] = false;
}
}
/// @dev Transfers the balance from msg.sender to an account
/// @param _to Recipient address
/// @param _amount Transfered amount in unit
/// @return Transfer status
function transfer(address _to, uint256 _amount)
public
isTradable
returns (bool) {
// if sender's balance has enough unit and amount >= 0,
// and the sum is not overflow,
// then do transfer
if ( (balances[msg.sender] >= _amount) &&
(_amount >= 0) &&
(balances[_to] + _amount > balances[_to]) ) {
balances[msg.sender] -= _amount;
balances[_to] += _amount;
Transfer(msg.sender, _to, _amount);
return true;
} else {
return false;
}
}
// Send _value amount of tokens from address _from to address _to
// The transferFrom method is used for a withdraw workflow, allowing contracts to send
// tokens on your behalf, for example to "deposit" to a contract address and/or to charge
// fees in sub-currencies; the command should fail unless the _from account has
// deliberately authorized the sender of the message via some mechanism; we propose
// these standardized APIs for approval:
function transferFrom(
address _from,
address _to,
uint256 _amount
)
public
isTradable
returns (bool success) {
if (balances[_from] >= _amount
&& allowed[_from][msg.sender] >= _amount
&& _amount > 0
&& balances[_to] + _amount > balances[_to]) {
balances[_from] -= _amount;
allowed[_from][msg.sender] -= _amount;
balances[_to] += _amount;
Transfer(_from, _to, _amount);
return true;
} else {
return false;
}
}
// Allow _spender to withdraw from your account, multiple times, up to the _value amount.
// If this function is called again it overwrites the current allowance with _value.
function approve(address _spender, uint256 _amount)
public
isTradable
returns (bool success) {
allowed[msg.sender][_spender] = _amount;
Approval(msg.sender, _spender, _amount);
return true;
}
// get allowance
function allowance(address _owner, address _spender)
public
constant
returns (uint256 remaining) {
return allowed[_owner][_spender];
}
/// @dev Withdraws Ether in contract (Owner only)
/// @return Status of withdrawal
function withdraw() onlyOwner
public
returns (bool) {
return owner.send(this.balance);
}
} | Gifto | function Gifto()
public {
owner = msg.sender;
setBuyPrice(_originalBuyPrice);
balances[owner] = _totalSupply;
Transfer(0x0, owner, _totalSupply);
}
| /// @dev Constructor | NatSpecSingleLine | v0.4.18+commit.9cf6e910 | bzzr://891e8485538f16f2fa5b9af11f8c795bc62d51fb6455063a6ee3652fa7680f20 | {
"func_code_index": [
3613,
3816
]
} | 3,516 |
|||
MultiSigWallet | MultiSigWallet.sol | 0x615ed6779507f223d04722d43ccc0cd871964e2a | Solidity | Gifto | contract Gifto is ERC20Interface {
uint256 public constant decimals = 5;
string public constant symbol = "GTO";
string public constant name = "Gifto";
bool public _selling = true;//initial selling
uint256 public _totalSupply = 10 ** 14; // total supply is 10^14 unit, equivalent to 10^9 Gifto
uint256 public _originalBuyPrice = 43 * 10**7; // original buy 1ETH = 4300 Gifto = 43 * 10**7 unit
// Owner of this contract
address public owner;
// Balances Gifto for each account
mapping(address => uint256) private balances;
// Owner of account approves the transfer of an amount to another account
mapping(address => mapping (address => uint256)) private allowed;
// List of approved investors
mapping(address => bool) private approvedInvestorList;
// deposit
mapping(address => uint256) private deposit;
// icoPercent
uint256 public _icoPercent = 10;
// _icoSupply is the avalable unit. Initially, it is _totalSupply
uint256 public _icoSupply = _totalSupply * _icoPercent / 100;
// minimum buy 0.3 ETH
uint256 public _minimumBuy = 3 * 10 ** 17;
// maximum buy 25 ETH
uint256 public _maximumBuy = 25 * 10 ** 18;
// totalTokenSold
uint256 public totalTokenSold = 0;
// tradable
bool public tradable = false;
/**
* Functions with this modifier can only be executed by the owner
*/
modifier onlyOwner() {
require(msg.sender == owner);
_;
}
/**
* Functions with this modifier check on sale status
* Only allow sale if _selling is on
*/
modifier onSale() {
require(_selling);
_;
}
/**
* Functions with this modifier check the validity of address is investor
*/
modifier validInvestor() {
require(approvedInvestorList[msg.sender]);
_;
}
/**
* Functions with this modifier check the validity of msg value
* value must greater than equal minimumBuyPrice
* total deposit must less than equal maximumBuyPrice
*/
modifier validValue(){
// require value >= _minimumBuy AND total deposit of msg.sender <= maximumBuyPrice
require ( (msg.value >= _minimumBuy) &&
( (deposit[msg.sender] + msg.value) <= _maximumBuy) );
_;
}
/**
*
*/
modifier isTradable(){
require(tradable == true || msg.sender == owner);
_;
}
/// @dev Fallback function allows to buy ether.
function()
public
payable {
buyGifto();
}
/// @dev buy function allows to buy ether. for using optional data
function buyGifto()
public
payable
onSale
validValue
validInvestor {
uint256 requestedUnits = (msg.value * _originalBuyPrice) / 10**18;
require(balances[owner] >= requestedUnits);
// prepare transfer data
balances[owner] -= requestedUnits;
balances[msg.sender] += requestedUnits;
// increase total deposit amount
deposit[msg.sender] += msg.value;
// check total and auto turnOffSale
totalTokenSold += requestedUnits;
if (totalTokenSold >= _icoSupply){
_selling = false;
}
// submit transfer
Transfer(owner, msg.sender, requestedUnits);
owner.transfer(msg.value);
}
/// @dev Constructor
function Gifto()
public {
owner = msg.sender;
setBuyPrice(_originalBuyPrice);
balances[owner] = _totalSupply;
Transfer(0x0, owner, _totalSupply);
}
/// @dev Gets totalSupply
/// @return Total supply
function totalSupply()
public
constant
returns (uint256) {
return _totalSupply;
}
/// @dev Enables sale
function turnOnSale() onlyOwner
public {
_selling = true;
}
/// @dev Disables sale
function turnOffSale() onlyOwner
public {
_selling = false;
}
function turnOnTradable()
public
onlyOwner{
tradable = true;
}
/// @dev set new icoPercent
/// @param newIcoPercent new value of icoPercent
function setIcoPercent(uint256 newIcoPercent)
public
onlyOwner {
_icoPercent = newIcoPercent;
_icoSupply = _totalSupply * _icoPercent / 100;
}
/// @dev set new _maximumBuy
/// @param newMaximumBuy new value of _maximumBuy
function setMaximumBuy(uint256 newMaximumBuy)
public
onlyOwner {
_maximumBuy = newMaximumBuy;
}
/// @dev Updates buy price (owner ONLY)
/// @param newBuyPrice New buy price (in unit)
function setBuyPrice(uint256 newBuyPrice)
onlyOwner
public {
require(newBuyPrice>0);
_originalBuyPrice = newBuyPrice; // 3000 Gifto = 3000 00000 unit
// control _maximumBuy_USD = 10,000 USD, Gifto price is 0.1USD
// maximumBuy_Gifto = 100,000 Gifto = 100,000,00000 unit
// 3000 Gifto = 1ETH => maximumETH = 100,000,00000 / _originalBuyPrice
// 100,000,00000/3000 0000 ~ 33ETH => change to wei
_maximumBuy = 10**18 * 10000000000 /_originalBuyPrice;
}
/// @dev Gets account's balance
/// @param _addr Address of the account
/// @return Account balance
function balanceOf(address _addr)
public
constant
returns (uint256) {
return balances[_addr];
}
/// @dev check address is approved investor
/// @param _addr address
function isApprovedInvestor(address _addr)
public
constant
returns (bool) {
return approvedInvestorList[_addr];
}
/// @dev get ETH deposit
/// @param _addr address get deposit
/// @return amount deposit of an buyer
function getDeposit(address _addr)
public
constant
returns(uint256){
return deposit[_addr];
}
/// @dev Adds list of new investors to the investors list and approve all
/// @param newInvestorList Array of new investors addresses to be added
function addInvestorList(address[] newInvestorList)
onlyOwner
public {
for (uint256 i = 0; i < newInvestorList.length; i++){
approvedInvestorList[newInvestorList[i]] = true;
}
}
/// @dev Removes list of investors from list
/// @param investorList Array of addresses of investors to be removed
function removeInvestorList(address[] investorList)
onlyOwner
public {
for (uint256 i = 0; i < investorList.length; i++){
approvedInvestorList[investorList[i]] = false;
}
}
/// @dev Transfers the balance from msg.sender to an account
/// @param _to Recipient address
/// @param _amount Transfered amount in unit
/// @return Transfer status
function transfer(address _to, uint256 _amount)
public
isTradable
returns (bool) {
// if sender's balance has enough unit and amount >= 0,
// and the sum is not overflow,
// then do transfer
if ( (balances[msg.sender] >= _amount) &&
(_amount >= 0) &&
(balances[_to] + _amount > balances[_to]) ) {
balances[msg.sender] -= _amount;
balances[_to] += _amount;
Transfer(msg.sender, _to, _amount);
return true;
} else {
return false;
}
}
// Send _value amount of tokens from address _from to address _to
// The transferFrom method is used for a withdraw workflow, allowing contracts to send
// tokens on your behalf, for example to "deposit" to a contract address and/or to charge
// fees in sub-currencies; the command should fail unless the _from account has
// deliberately authorized the sender of the message via some mechanism; we propose
// these standardized APIs for approval:
function transferFrom(
address _from,
address _to,
uint256 _amount
)
public
isTradable
returns (bool success) {
if (balances[_from] >= _amount
&& allowed[_from][msg.sender] >= _amount
&& _amount > 0
&& balances[_to] + _amount > balances[_to]) {
balances[_from] -= _amount;
allowed[_from][msg.sender] -= _amount;
balances[_to] += _amount;
Transfer(_from, _to, _amount);
return true;
} else {
return false;
}
}
// Allow _spender to withdraw from your account, multiple times, up to the _value amount.
// If this function is called again it overwrites the current allowance with _value.
function approve(address _spender, uint256 _amount)
public
isTradable
returns (bool success) {
allowed[msg.sender][_spender] = _amount;
Approval(msg.sender, _spender, _amount);
return true;
}
// get allowance
function allowance(address _owner, address _spender)
public
constant
returns (uint256 remaining) {
return allowed[_owner][_spender];
}
/// @dev Withdraws Ether in contract (Owner only)
/// @return Status of withdrawal
function withdraw() onlyOwner
public
returns (bool) {
return owner.send(this.balance);
}
} | totalSupply | function totalSupply()
public
constant
returns (uint256) {
return _totalSupply;
}
| /// @dev Gets totalSupply
/// @return Total supply | NatSpecSingleLine | v0.4.18+commit.9cf6e910 | bzzr://891e8485538f16f2fa5b9af11f8c795bc62d51fb6455063a6ee3652fa7680f20 | {
"func_code_index": [
3884,
4013
]
} | 3,517 |
|||
MultiSigWallet | MultiSigWallet.sol | 0x615ed6779507f223d04722d43ccc0cd871964e2a | Solidity | Gifto | contract Gifto is ERC20Interface {
uint256 public constant decimals = 5;
string public constant symbol = "GTO";
string public constant name = "Gifto";
bool public _selling = true;//initial selling
uint256 public _totalSupply = 10 ** 14; // total supply is 10^14 unit, equivalent to 10^9 Gifto
uint256 public _originalBuyPrice = 43 * 10**7; // original buy 1ETH = 4300 Gifto = 43 * 10**7 unit
// Owner of this contract
address public owner;
// Balances Gifto for each account
mapping(address => uint256) private balances;
// Owner of account approves the transfer of an amount to another account
mapping(address => mapping (address => uint256)) private allowed;
// List of approved investors
mapping(address => bool) private approvedInvestorList;
// deposit
mapping(address => uint256) private deposit;
// icoPercent
uint256 public _icoPercent = 10;
// _icoSupply is the avalable unit. Initially, it is _totalSupply
uint256 public _icoSupply = _totalSupply * _icoPercent / 100;
// minimum buy 0.3 ETH
uint256 public _minimumBuy = 3 * 10 ** 17;
// maximum buy 25 ETH
uint256 public _maximumBuy = 25 * 10 ** 18;
// totalTokenSold
uint256 public totalTokenSold = 0;
// tradable
bool public tradable = false;
/**
* Functions with this modifier can only be executed by the owner
*/
modifier onlyOwner() {
require(msg.sender == owner);
_;
}
/**
* Functions with this modifier check on sale status
* Only allow sale if _selling is on
*/
modifier onSale() {
require(_selling);
_;
}
/**
* Functions with this modifier check the validity of address is investor
*/
modifier validInvestor() {
require(approvedInvestorList[msg.sender]);
_;
}
/**
* Functions with this modifier check the validity of msg value
* value must greater than equal minimumBuyPrice
* total deposit must less than equal maximumBuyPrice
*/
modifier validValue(){
// require value >= _minimumBuy AND total deposit of msg.sender <= maximumBuyPrice
require ( (msg.value >= _minimumBuy) &&
( (deposit[msg.sender] + msg.value) <= _maximumBuy) );
_;
}
/**
*
*/
modifier isTradable(){
require(tradable == true || msg.sender == owner);
_;
}
/// @dev Fallback function allows to buy ether.
function()
public
payable {
buyGifto();
}
/// @dev buy function allows to buy ether. for using optional data
function buyGifto()
public
payable
onSale
validValue
validInvestor {
uint256 requestedUnits = (msg.value * _originalBuyPrice) / 10**18;
require(balances[owner] >= requestedUnits);
// prepare transfer data
balances[owner] -= requestedUnits;
balances[msg.sender] += requestedUnits;
// increase total deposit amount
deposit[msg.sender] += msg.value;
// check total and auto turnOffSale
totalTokenSold += requestedUnits;
if (totalTokenSold >= _icoSupply){
_selling = false;
}
// submit transfer
Transfer(owner, msg.sender, requestedUnits);
owner.transfer(msg.value);
}
/// @dev Constructor
function Gifto()
public {
owner = msg.sender;
setBuyPrice(_originalBuyPrice);
balances[owner] = _totalSupply;
Transfer(0x0, owner, _totalSupply);
}
/// @dev Gets totalSupply
/// @return Total supply
function totalSupply()
public
constant
returns (uint256) {
return _totalSupply;
}
/// @dev Enables sale
function turnOnSale() onlyOwner
public {
_selling = true;
}
/// @dev Disables sale
function turnOffSale() onlyOwner
public {
_selling = false;
}
function turnOnTradable()
public
onlyOwner{
tradable = true;
}
/// @dev set new icoPercent
/// @param newIcoPercent new value of icoPercent
function setIcoPercent(uint256 newIcoPercent)
public
onlyOwner {
_icoPercent = newIcoPercent;
_icoSupply = _totalSupply * _icoPercent / 100;
}
/// @dev set new _maximumBuy
/// @param newMaximumBuy new value of _maximumBuy
function setMaximumBuy(uint256 newMaximumBuy)
public
onlyOwner {
_maximumBuy = newMaximumBuy;
}
/// @dev Updates buy price (owner ONLY)
/// @param newBuyPrice New buy price (in unit)
function setBuyPrice(uint256 newBuyPrice)
onlyOwner
public {
require(newBuyPrice>0);
_originalBuyPrice = newBuyPrice; // 3000 Gifto = 3000 00000 unit
// control _maximumBuy_USD = 10,000 USD, Gifto price is 0.1USD
// maximumBuy_Gifto = 100,000 Gifto = 100,000,00000 unit
// 3000 Gifto = 1ETH => maximumETH = 100,000,00000 / _originalBuyPrice
// 100,000,00000/3000 0000 ~ 33ETH => change to wei
_maximumBuy = 10**18 * 10000000000 /_originalBuyPrice;
}
/// @dev Gets account's balance
/// @param _addr Address of the account
/// @return Account balance
function balanceOf(address _addr)
public
constant
returns (uint256) {
return balances[_addr];
}
/// @dev check address is approved investor
/// @param _addr address
function isApprovedInvestor(address _addr)
public
constant
returns (bool) {
return approvedInvestorList[_addr];
}
/// @dev get ETH deposit
/// @param _addr address get deposit
/// @return amount deposit of an buyer
function getDeposit(address _addr)
public
constant
returns(uint256){
return deposit[_addr];
}
/// @dev Adds list of new investors to the investors list and approve all
/// @param newInvestorList Array of new investors addresses to be added
function addInvestorList(address[] newInvestorList)
onlyOwner
public {
for (uint256 i = 0; i < newInvestorList.length; i++){
approvedInvestorList[newInvestorList[i]] = true;
}
}
/// @dev Removes list of investors from list
/// @param investorList Array of addresses of investors to be removed
function removeInvestorList(address[] investorList)
onlyOwner
public {
for (uint256 i = 0; i < investorList.length; i++){
approvedInvestorList[investorList[i]] = false;
}
}
/// @dev Transfers the balance from msg.sender to an account
/// @param _to Recipient address
/// @param _amount Transfered amount in unit
/// @return Transfer status
function transfer(address _to, uint256 _amount)
public
isTradable
returns (bool) {
// if sender's balance has enough unit and amount >= 0,
// and the sum is not overflow,
// then do transfer
if ( (balances[msg.sender] >= _amount) &&
(_amount >= 0) &&
(balances[_to] + _amount > balances[_to]) ) {
balances[msg.sender] -= _amount;
balances[_to] += _amount;
Transfer(msg.sender, _to, _amount);
return true;
} else {
return false;
}
}
// Send _value amount of tokens from address _from to address _to
// The transferFrom method is used for a withdraw workflow, allowing contracts to send
// tokens on your behalf, for example to "deposit" to a contract address and/or to charge
// fees in sub-currencies; the command should fail unless the _from account has
// deliberately authorized the sender of the message via some mechanism; we propose
// these standardized APIs for approval:
function transferFrom(
address _from,
address _to,
uint256 _amount
)
public
isTradable
returns (bool success) {
if (balances[_from] >= _amount
&& allowed[_from][msg.sender] >= _amount
&& _amount > 0
&& balances[_to] + _amount > balances[_to]) {
balances[_from] -= _amount;
allowed[_from][msg.sender] -= _amount;
balances[_to] += _amount;
Transfer(_from, _to, _amount);
return true;
} else {
return false;
}
}
// Allow _spender to withdraw from your account, multiple times, up to the _value amount.
// If this function is called again it overwrites the current allowance with _value.
function approve(address _spender, uint256 _amount)
public
isTradable
returns (bool success) {
allowed[msg.sender][_spender] = _amount;
Approval(msg.sender, _spender, _amount);
return true;
}
// get allowance
function allowance(address _owner, address _spender)
public
constant
returns (uint256 remaining) {
return allowed[_owner][_spender];
}
/// @dev Withdraws Ether in contract (Owner only)
/// @return Status of withdrawal
function withdraw() onlyOwner
public
returns (bool) {
return owner.send(this.balance);
}
} | turnOnSale | function turnOnSale() onlyOwner
public {
_selling = true;
}
| /// @dev Enables sale | NatSpecSingleLine | v0.4.18+commit.9cf6e910 | bzzr://891e8485538f16f2fa5b9af11f8c795bc62d51fb6455063a6ee3652fa7680f20 | {
"func_code_index": [
4048,
4136
]
} | 3,518 |
|||
MultiSigWallet | MultiSigWallet.sol | 0x615ed6779507f223d04722d43ccc0cd871964e2a | Solidity | Gifto | contract Gifto is ERC20Interface {
uint256 public constant decimals = 5;
string public constant symbol = "GTO";
string public constant name = "Gifto";
bool public _selling = true;//initial selling
uint256 public _totalSupply = 10 ** 14; // total supply is 10^14 unit, equivalent to 10^9 Gifto
uint256 public _originalBuyPrice = 43 * 10**7; // original buy 1ETH = 4300 Gifto = 43 * 10**7 unit
// Owner of this contract
address public owner;
// Balances Gifto for each account
mapping(address => uint256) private balances;
// Owner of account approves the transfer of an amount to another account
mapping(address => mapping (address => uint256)) private allowed;
// List of approved investors
mapping(address => bool) private approvedInvestorList;
// deposit
mapping(address => uint256) private deposit;
// icoPercent
uint256 public _icoPercent = 10;
// _icoSupply is the avalable unit. Initially, it is _totalSupply
uint256 public _icoSupply = _totalSupply * _icoPercent / 100;
// minimum buy 0.3 ETH
uint256 public _minimumBuy = 3 * 10 ** 17;
// maximum buy 25 ETH
uint256 public _maximumBuy = 25 * 10 ** 18;
// totalTokenSold
uint256 public totalTokenSold = 0;
// tradable
bool public tradable = false;
/**
* Functions with this modifier can only be executed by the owner
*/
modifier onlyOwner() {
require(msg.sender == owner);
_;
}
/**
* Functions with this modifier check on sale status
* Only allow sale if _selling is on
*/
modifier onSale() {
require(_selling);
_;
}
/**
* Functions with this modifier check the validity of address is investor
*/
modifier validInvestor() {
require(approvedInvestorList[msg.sender]);
_;
}
/**
* Functions with this modifier check the validity of msg value
* value must greater than equal minimumBuyPrice
* total deposit must less than equal maximumBuyPrice
*/
modifier validValue(){
// require value >= _minimumBuy AND total deposit of msg.sender <= maximumBuyPrice
require ( (msg.value >= _minimumBuy) &&
( (deposit[msg.sender] + msg.value) <= _maximumBuy) );
_;
}
/**
*
*/
modifier isTradable(){
require(tradable == true || msg.sender == owner);
_;
}
/// @dev Fallback function allows to buy ether.
function()
public
payable {
buyGifto();
}
/// @dev buy function allows to buy ether. for using optional data
function buyGifto()
public
payable
onSale
validValue
validInvestor {
uint256 requestedUnits = (msg.value * _originalBuyPrice) / 10**18;
require(balances[owner] >= requestedUnits);
// prepare transfer data
balances[owner] -= requestedUnits;
balances[msg.sender] += requestedUnits;
// increase total deposit amount
deposit[msg.sender] += msg.value;
// check total and auto turnOffSale
totalTokenSold += requestedUnits;
if (totalTokenSold >= _icoSupply){
_selling = false;
}
// submit transfer
Transfer(owner, msg.sender, requestedUnits);
owner.transfer(msg.value);
}
/// @dev Constructor
function Gifto()
public {
owner = msg.sender;
setBuyPrice(_originalBuyPrice);
balances[owner] = _totalSupply;
Transfer(0x0, owner, _totalSupply);
}
/// @dev Gets totalSupply
/// @return Total supply
function totalSupply()
public
constant
returns (uint256) {
return _totalSupply;
}
/// @dev Enables sale
function turnOnSale() onlyOwner
public {
_selling = true;
}
/// @dev Disables sale
function turnOffSale() onlyOwner
public {
_selling = false;
}
function turnOnTradable()
public
onlyOwner{
tradable = true;
}
/// @dev set new icoPercent
/// @param newIcoPercent new value of icoPercent
function setIcoPercent(uint256 newIcoPercent)
public
onlyOwner {
_icoPercent = newIcoPercent;
_icoSupply = _totalSupply * _icoPercent / 100;
}
/// @dev set new _maximumBuy
/// @param newMaximumBuy new value of _maximumBuy
function setMaximumBuy(uint256 newMaximumBuy)
public
onlyOwner {
_maximumBuy = newMaximumBuy;
}
/// @dev Updates buy price (owner ONLY)
/// @param newBuyPrice New buy price (in unit)
function setBuyPrice(uint256 newBuyPrice)
onlyOwner
public {
require(newBuyPrice>0);
_originalBuyPrice = newBuyPrice; // 3000 Gifto = 3000 00000 unit
// control _maximumBuy_USD = 10,000 USD, Gifto price is 0.1USD
// maximumBuy_Gifto = 100,000 Gifto = 100,000,00000 unit
// 3000 Gifto = 1ETH => maximumETH = 100,000,00000 / _originalBuyPrice
// 100,000,00000/3000 0000 ~ 33ETH => change to wei
_maximumBuy = 10**18 * 10000000000 /_originalBuyPrice;
}
/// @dev Gets account's balance
/// @param _addr Address of the account
/// @return Account balance
function balanceOf(address _addr)
public
constant
returns (uint256) {
return balances[_addr];
}
/// @dev check address is approved investor
/// @param _addr address
function isApprovedInvestor(address _addr)
public
constant
returns (bool) {
return approvedInvestorList[_addr];
}
/// @dev get ETH deposit
/// @param _addr address get deposit
/// @return amount deposit of an buyer
function getDeposit(address _addr)
public
constant
returns(uint256){
return deposit[_addr];
}
/// @dev Adds list of new investors to the investors list and approve all
/// @param newInvestorList Array of new investors addresses to be added
function addInvestorList(address[] newInvestorList)
onlyOwner
public {
for (uint256 i = 0; i < newInvestorList.length; i++){
approvedInvestorList[newInvestorList[i]] = true;
}
}
/// @dev Removes list of investors from list
/// @param investorList Array of addresses of investors to be removed
function removeInvestorList(address[] investorList)
onlyOwner
public {
for (uint256 i = 0; i < investorList.length; i++){
approvedInvestorList[investorList[i]] = false;
}
}
/// @dev Transfers the balance from msg.sender to an account
/// @param _to Recipient address
/// @param _amount Transfered amount in unit
/// @return Transfer status
function transfer(address _to, uint256 _amount)
public
isTradable
returns (bool) {
// if sender's balance has enough unit and amount >= 0,
// and the sum is not overflow,
// then do transfer
if ( (balances[msg.sender] >= _amount) &&
(_amount >= 0) &&
(balances[_to] + _amount > balances[_to]) ) {
balances[msg.sender] -= _amount;
balances[_to] += _amount;
Transfer(msg.sender, _to, _amount);
return true;
} else {
return false;
}
}
// Send _value amount of tokens from address _from to address _to
// The transferFrom method is used for a withdraw workflow, allowing contracts to send
// tokens on your behalf, for example to "deposit" to a contract address and/or to charge
// fees in sub-currencies; the command should fail unless the _from account has
// deliberately authorized the sender of the message via some mechanism; we propose
// these standardized APIs for approval:
function transferFrom(
address _from,
address _to,
uint256 _amount
)
public
isTradable
returns (bool success) {
if (balances[_from] >= _amount
&& allowed[_from][msg.sender] >= _amount
&& _amount > 0
&& balances[_to] + _amount > balances[_to]) {
balances[_from] -= _amount;
allowed[_from][msg.sender] -= _amount;
balances[_to] += _amount;
Transfer(_from, _to, _amount);
return true;
} else {
return false;
}
}
// Allow _spender to withdraw from your account, multiple times, up to the _value amount.
// If this function is called again it overwrites the current allowance with _value.
function approve(address _spender, uint256 _amount)
public
isTradable
returns (bool success) {
allowed[msg.sender][_spender] = _amount;
Approval(msg.sender, _spender, _amount);
return true;
}
// get allowance
function allowance(address _owner, address _spender)
public
constant
returns (uint256 remaining) {
return allowed[_owner][_spender];
}
/// @dev Withdraws Ether in contract (Owner only)
/// @return Status of withdrawal
function withdraw() onlyOwner
public
returns (bool) {
return owner.send(this.balance);
}
} | turnOffSale | function turnOffSale() onlyOwner
public {
_selling = false;
}
| /// @dev Disables sale | NatSpecSingleLine | v0.4.18+commit.9cf6e910 | bzzr://891e8485538f16f2fa5b9af11f8c795bc62d51fb6455063a6ee3652fa7680f20 | {
"func_code_index": [
4167,
4257
]
} | 3,519 |
|||
MultiSigWallet | MultiSigWallet.sol | 0x615ed6779507f223d04722d43ccc0cd871964e2a | Solidity | Gifto | contract Gifto is ERC20Interface {
uint256 public constant decimals = 5;
string public constant symbol = "GTO";
string public constant name = "Gifto";
bool public _selling = true;//initial selling
uint256 public _totalSupply = 10 ** 14; // total supply is 10^14 unit, equivalent to 10^9 Gifto
uint256 public _originalBuyPrice = 43 * 10**7; // original buy 1ETH = 4300 Gifto = 43 * 10**7 unit
// Owner of this contract
address public owner;
// Balances Gifto for each account
mapping(address => uint256) private balances;
// Owner of account approves the transfer of an amount to another account
mapping(address => mapping (address => uint256)) private allowed;
// List of approved investors
mapping(address => bool) private approvedInvestorList;
// deposit
mapping(address => uint256) private deposit;
// icoPercent
uint256 public _icoPercent = 10;
// _icoSupply is the avalable unit. Initially, it is _totalSupply
uint256 public _icoSupply = _totalSupply * _icoPercent / 100;
// minimum buy 0.3 ETH
uint256 public _minimumBuy = 3 * 10 ** 17;
// maximum buy 25 ETH
uint256 public _maximumBuy = 25 * 10 ** 18;
// totalTokenSold
uint256 public totalTokenSold = 0;
// tradable
bool public tradable = false;
/**
* Functions with this modifier can only be executed by the owner
*/
modifier onlyOwner() {
require(msg.sender == owner);
_;
}
/**
* Functions with this modifier check on sale status
* Only allow sale if _selling is on
*/
modifier onSale() {
require(_selling);
_;
}
/**
* Functions with this modifier check the validity of address is investor
*/
modifier validInvestor() {
require(approvedInvestorList[msg.sender]);
_;
}
/**
* Functions with this modifier check the validity of msg value
* value must greater than equal minimumBuyPrice
* total deposit must less than equal maximumBuyPrice
*/
modifier validValue(){
// require value >= _minimumBuy AND total deposit of msg.sender <= maximumBuyPrice
require ( (msg.value >= _minimumBuy) &&
( (deposit[msg.sender] + msg.value) <= _maximumBuy) );
_;
}
/**
*
*/
modifier isTradable(){
require(tradable == true || msg.sender == owner);
_;
}
/// @dev Fallback function allows to buy ether.
function()
public
payable {
buyGifto();
}
/// @dev buy function allows to buy ether. for using optional data
function buyGifto()
public
payable
onSale
validValue
validInvestor {
uint256 requestedUnits = (msg.value * _originalBuyPrice) / 10**18;
require(balances[owner] >= requestedUnits);
// prepare transfer data
balances[owner] -= requestedUnits;
balances[msg.sender] += requestedUnits;
// increase total deposit amount
deposit[msg.sender] += msg.value;
// check total and auto turnOffSale
totalTokenSold += requestedUnits;
if (totalTokenSold >= _icoSupply){
_selling = false;
}
// submit transfer
Transfer(owner, msg.sender, requestedUnits);
owner.transfer(msg.value);
}
/// @dev Constructor
function Gifto()
public {
owner = msg.sender;
setBuyPrice(_originalBuyPrice);
balances[owner] = _totalSupply;
Transfer(0x0, owner, _totalSupply);
}
/// @dev Gets totalSupply
/// @return Total supply
function totalSupply()
public
constant
returns (uint256) {
return _totalSupply;
}
/// @dev Enables sale
function turnOnSale() onlyOwner
public {
_selling = true;
}
/// @dev Disables sale
function turnOffSale() onlyOwner
public {
_selling = false;
}
function turnOnTradable()
public
onlyOwner{
tradable = true;
}
/// @dev set new icoPercent
/// @param newIcoPercent new value of icoPercent
function setIcoPercent(uint256 newIcoPercent)
public
onlyOwner {
_icoPercent = newIcoPercent;
_icoSupply = _totalSupply * _icoPercent / 100;
}
/// @dev set new _maximumBuy
/// @param newMaximumBuy new value of _maximumBuy
function setMaximumBuy(uint256 newMaximumBuy)
public
onlyOwner {
_maximumBuy = newMaximumBuy;
}
/// @dev Updates buy price (owner ONLY)
/// @param newBuyPrice New buy price (in unit)
function setBuyPrice(uint256 newBuyPrice)
onlyOwner
public {
require(newBuyPrice>0);
_originalBuyPrice = newBuyPrice; // 3000 Gifto = 3000 00000 unit
// control _maximumBuy_USD = 10,000 USD, Gifto price is 0.1USD
// maximumBuy_Gifto = 100,000 Gifto = 100,000,00000 unit
// 3000 Gifto = 1ETH => maximumETH = 100,000,00000 / _originalBuyPrice
// 100,000,00000/3000 0000 ~ 33ETH => change to wei
_maximumBuy = 10**18 * 10000000000 /_originalBuyPrice;
}
/// @dev Gets account's balance
/// @param _addr Address of the account
/// @return Account balance
function balanceOf(address _addr)
public
constant
returns (uint256) {
return balances[_addr];
}
/// @dev check address is approved investor
/// @param _addr address
function isApprovedInvestor(address _addr)
public
constant
returns (bool) {
return approvedInvestorList[_addr];
}
/// @dev get ETH deposit
/// @param _addr address get deposit
/// @return amount deposit of an buyer
function getDeposit(address _addr)
public
constant
returns(uint256){
return deposit[_addr];
}
/// @dev Adds list of new investors to the investors list and approve all
/// @param newInvestorList Array of new investors addresses to be added
function addInvestorList(address[] newInvestorList)
onlyOwner
public {
for (uint256 i = 0; i < newInvestorList.length; i++){
approvedInvestorList[newInvestorList[i]] = true;
}
}
/// @dev Removes list of investors from list
/// @param investorList Array of addresses of investors to be removed
function removeInvestorList(address[] investorList)
onlyOwner
public {
for (uint256 i = 0; i < investorList.length; i++){
approvedInvestorList[investorList[i]] = false;
}
}
/// @dev Transfers the balance from msg.sender to an account
/// @param _to Recipient address
/// @param _amount Transfered amount in unit
/// @return Transfer status
function transfer(address _to, uint256 _amount)
public
isTradable
returns (bool) {
// if sender's balance has enough unit and amount >= 0,
// and the sum is not overflow,
// then do transfer
if ( (balances[msg.sender] >= _amount) &&
(_amount >= 0) &&
(balances[_to] + _amount > balances[_to]) ) {
balances[msg.sender] -= _amount;
balances[_to] += _amount;
Transfer(msg.sender, _to, _amount);
return true;
} else {
return false;
}
}
// Send _value amount of tokens from address _from to address _to
// The transferFrom method is used for a withdraw workflow, allowing contracts to send
// tokens on your behalf, for example to "deposit" to a contract address and/or to charge
// fees in sub-currencies; the command should fail unless the _from account has
// deliberately authorized the sender of the message via some mechanism; we propose
// these standardized APIs for approval:
function transferFrom(
address _from,
address _to,
uint256 _amount
)
public
isTradable
returns (bool success) {
if (balances[_from] >= _amount
&& allowed[_from][msg.sender] >= _amount
&& _amount > 0
&& balances[_to] + _amount > balances[_to]) {
balances[_from] -= _amount;
allowed[_from][msg.sender] -= _amount;
balances[_to] += _amount;
Transfer(_from, _to, _amount);
return true;
} else {
return false;
}
}
// Allow _spender to withdraw from your account, multiple times, up to the _value amount.
// If this function is called again it overwrites the current allowance with _value.
function approve(address _spender, uint256 _amount)
public
isTradable
returns (bool success) {
allowed[msg.sender][_spender] = _amount;
Approval(msg.sender, _spender, _amount);
return true;
}
// get allowance
function allowance(address _owner, address _spender)
public
constant
returns (uint256 remaining) {
return allowed[_owner][_spender];
}
/// @dev Withdraws Ether in contract (Owner only)
/// @return Status of withdrawal
function withdraw() onlyOwner
public
returns (bool) {
return owner.send(this.balance);
}
} | setIcoPercent | function setIcoPercent(uint256 newIcoPercent)
public
onlyOwner {
_icoPercent = newIcoPercent;
_icoSupply = _totalSupply * _icoPercent / 100;
}
| /// @dev set new icoPercent
/// @param newIcoPercent new value of icoPercent | NatSpecSingleLine | v0.4.18+commit.9cf6e910 | bzzr://891e8485538f16f2fa5b9af11f8c795bc62d51fb6455063a6ee3652fa7680f20 | {
"func_code_index": [
4458,
4647
]
} | 3,520 |
|||
MultiSigWallet | MultiSigWallet.sol | 0x615ed6779507f223d04722d43ccc0cd871964e2a | Solidity | Gifto | contract Gifto is ERC20Interface {
uint256 public constant decimals = 5;
string public constant symbol = "GTO";
string public constant name = "Gifto";
bool public _selling = true;//initial selling
uint256 public _totalSupply = 10 ** 14; // total supply is 10^14 unit, equivalent to 10^9 Gifto
uint256 public _originalBuyPrice = 43 * 10**7; // original buy 1ETH = 4300 Gifto = 43 * 10**7 unit
// Owner of this contract
address public owner;
// Balances Gifto for each account
mapping(address => uint256) private balances;
// Owner of account approves the transfer of an amount to another account
mapping(address => mapping (address => uint256)) private allowed;
// List of approved investors
mapping(address => bool) private approvedInvestorList;
// deposit
mapping(address => uint256) private deposit;
// icoPercent
uint256 public _icoPercent = 10;
// _icoSupply is the avalable unit. Initially, it is _totalSupply
uint256 public _icoSupply = _totalSupply * _icoPercent / 100;
// minimum buy 0.3 ETH
uint256 public _minimumBuy = 3 * 10 ** 17;
// maximum buy 25 ETH
uint256 public _maximumBuy = 25 * 10 ** 18;
// totalTokenSold
uint256 public totalTokenSold = 0;
// tradable
bool public tradable = false;
/**
* Functions with this modifier can only be executed by the owner
*/
modifier onlyOwner() {
require(msg.sender == owner);
_;
}
/**
* Functions with this modifier check on sale status
* Only allow sale if _selling is on
*/
modifier onSale() {
require(_selling);
_;
}
/**
* Functions with this modifier check the validity of address is investor
*/
modifier validInvestor() {
require(approvedInvestorList[msg.sender]);
_;
}
/**
* Functions with this modifier check the validity of msg value
* value must greater than equal minimumBuyPrice
* total deposit must less than equal maximumBuyPrice
*/
modifier validValue(){
// require value >= _minimumBuy AND total deposit of msg.sender <= maximumBuyPrice
require ( (msg.value >= _minimumBuy) &&
( (deposit[msg.sender] + msg.value) <= _maximumBuy) );
_;
}
/**
*
*/
modifier isTradable(){
require(tradable == true || msg.sender == owner);
_;
}
/// @dev Fallback function allows to buy ether.
function()
public
payable {
buyGifto();
}
/// @dev buy function allows to buy ether. for using optional data
function buyGifto()
public
payable
onSale
validValue
validInvestor {
uint256 requestedUnits = (msg.value * _originalBuyPrice) / 10**18;
require(balances[owner] >= requestedUnits);
// prepare transfer data
balances[owner] -= requestedUnits;
balances[msg.sender] += requestedUnits;
// increase total deposit amount
deposit[msg.sender] += msg.value;
// check total and auto turnOffSale
totalTokenSold += requestedUnits;
if (totalTokenSold >= _icoSupply){
_selling = false;
}
// submit transfer
Transfer(owner, msg.sender, requestedUnits);
owner.transfer(msg.value);
}
/// @dev Constructor
function Gifto()
public {
owner = msg.sender;
setBuyPrice(_originalBuyPrice);
balances[owner] = _totalSupply;
Transfer(0x0, owner, _totalSupply);
}
/// @dev Gets totalSupply
/// @return Total supply
function totalSupply()
public
constant
returns (uint256) {
return _totalSupply;
}
/// @dev Enables sale
function turnOnSale() onlyOwner
public {
_selling = true;
}
/// @dev Disables sale
function turnOffSale() onlyOwner
public {
_selling = false;
}
function turnOnTradable()
public
onlyOwner{
tradable = true;
}
/// @dev set new icoPercent
/// @param newIcoPercent new value of icoPercent
function setIcoPercent(uint256 newIcoPercent)
public
onlyOwner {
_icoPercent = newIcoPercent;
_icoSupply = _totalSupply * _icoPercent / 100;
}
/// @dev set new _maximumBuy
/// @param newMaximumBuy new value of _maximumBuy
function setMaximumBuy(uint256 newMaximumBuy)
public
onlyOwner {
_maximumBuy = newMaximumBuy;
}
/// @dev Updates buy price (owner ONLY)
/// @param newBuyPrice New buy price (in unit)
function setBuyPrice(uint256 newBuyPrice)
onlyOwner
public {
require(newBuyPrice>0);
_originalBuyPrice = newBuyPrice; // 3000 Gifto = 3000 00000 unit
// control _maximumBuy_USD = 10,000 USD, Gifto price is 0.1USD
// maximumBuy_Gifto = 100,000 Gifto = 100,000,00000 unit
// 3000 Gifto = 1ETH => maximumETH = 100,000,00000 / _originalBuyPrice
// 100,000,00000/3000 0000 ~ 33ETH => change to wei
_maximumBuy = 10**18 * 10000000000 /_originalBuyPrice;
}
/// @dev Gets account's balance
/// @param _addr Address of the account
/// @return Account balance
function balanceOf(address _addr)
public
constant
returns (uint256) {
return balances[_addr];
}
/// @dev check address is approved investor
/// @param _addr address
function isApprovedInvestor(address _addr)
public
constant
returns (bool) {
return approvedInvestorList[_addr];
}
/// @dev get ETH deposit
/// @param _addr address get deposit
/// @return amount deposit of an buyer
function getDeposit(address _addr)
public
constant
returns(uint256){
return deposit[_addr];
}
/// @dev Adds list of new investors to the investors list and approve all
/// @param newInvestorList Array of new investors addresses to be added
function addInvestorList(address[] newInvestorList)
onlyOwner
public {
for (uint256 i = 0; i < newInvestorList.length; i++){
approvedInvestorList[newInvestorList[i]] = true;
}
}
/// @dev Removes list of investors from list
/// @param investorList Array of addresses of investors to be removed
function removeInvestorList(address[] investorList)
onlyOwner
public {
for (uint256 i = 0; i < investorList.length; i++){
approvedInvestorList[investorList[i]] = false;
}
}
/// @dev Transfers the balance from msg.sender to an account
/// @param _to Recipient address
/// @param _amount Transfered amount in unit
/// @return Transfer status
function transfer(address _to, uint256 _amount)
public
isTradable
returns (bool) {
// if sender's balance has enough unit and amount >= 0,
// and the sum is not overflow,
// then do transfer
if ( (balances[msg.sender] >= _amount) &&
(_amount >= 0) &&
(balances[_to] + _amount > balances[_to]) ) {
balances[msg.sender] -= _amount;
balances[_to] += _amount;
Transfer(msg.sender, _to, _amount);
return true;
} else {
return false;
}
}
// Send _value amount of tokens from address _from to address _to
// The transferFrom method is used for a withdraw workflow, allowing contracts to send
// tokens on your behalf, for example to "deposit" to a contract address and/or to charge
// fees in sub-currencies; the command should fail unless the _from account has
// deliberately authorized the sender of the message via some mechanism; we propose
// these standardized APIs for approval:
function transferFrom(
address _from,
address _to,
uint256 _amount
)
public
isTradable
returns (bool success) {
if (balances[_from] >= _amount
&& allowed[_from][msg.sender] >= _amount
&& _amount > 0
&& balances[_to] + _amount > balances[_to]) {
balances[_from] -= _amount;
allowed[_from][msg.sender] -= _amount;
balances[_to] += _amount;
Transfer(_from, _to, _amount);
return true;
} else {
return false;
}
}
// Allow _spender to withdraw from your account, multiple times, up to the _value amount.
// If this function is called again it overwrites the current allowance with _value.
function approve(address _spender, uint256 _amount)
public
isTradable
returns (bool success) {
allowed[msg.sender][_spender] = _amount;
Approval(msg.sender, _spender, _amount);
return true;
}
// get allowance
function allowance(address _owner, address _spender)
public
constant
returns (uint256 remaining) {
return allowed[_owner][_spender];
}
/// @dev Withdraws Ether in contract (Owner only)
/// @return Status of withdrawal
function withdraw() onlyOwner
public
returns (bool) {
return owner.send(this.balance);
}
} | setMaximumBuy | function setMaximumBuy(uint256 newMaximumBuy)
public
onlyOwner {
_maximumBuy = newMaximumBuy;
}
| /// @dev set new _maximumBuy
/// @param newMaximumBuy new value of _maximumBuy | NatSpecSingleLine | v0.4.18+commit.9cf6e910 | bzzr://891e8485538f16f2fa5b9af11f8c795bc62d51fb6455063a6ee3652fa7680f20 | {
"func_code_index": [
4743,
4876
]
} | 3,521 |
|||
MultiSigWallet | MultiSigWallet.sol | 0x615ed6779507f223d04722d43ccc0cd871964e2a | Solidity | Gifto | contract Gifto is ERC20Interface {
uint256 public constant decimals = 5;
string public constant symbol = "GTO";
string public constant name = "Gifto";
bool public _selling = true;//initial selling
uint256 public _totalSupply = 10 ** 14; // total supply is 10^14 unit, equivalent to 10^9 Gifto
uint256 public _originalBuyPrice = 43 * 10**7; // original buy 1ETH = 4300 Gifto = 43 * 10**7 unit
// Owner of this contract
address public owner;
// Balances Gifto for each account
mapping(address => uint256) private balances;
// Owner of account approves the transfer of an amount to another account
mapping(address => mapping (address => uint256)) private allowed;
// List of approved investors
mapping(address => bool) private approvedInvestorList;
// deposit
mapping(address => uint256) private deposit;
// icoPercent
uint256 public _icoPercent = 10;
// _icoSupply is the avalable unit. Initially, it is _totalSupply
uint256 public _icoSupply = _totalSupply * _icoPercent / 100;
// minimum buy 0.3 ETH
uint256 public _minimumBuy = 3 * 10 ** 17;
// maximum buy 25 ETH
uint256 public _maximumBuy = 25 * 10 ** 18;
// totalTokenSold
uint256 public totalTokenSold = 0;
// tradable
bool public tradable = false;
/**
* Functions with this modifier can only be executed by the owner
*/
modifier onlyOwner() {
require(msg.sender == owner);
_;
}
/**
* Functions with this modifier check on sale status
* Only allow sale if _selling is on
*/
modifier onSale() {
require(_selling);
_;
}
/**
* Functions with this modifier check the validity of address is investor
*/
modifier validInvestor() {
require(approvedInvestorList[msg.sender]);
_;
}
/**
* Functions with this modifier check the validity of msg value
* value must greater than equal minimumBuyPrice
* total deposit must less than equal maximumBuyPrice
*/
modifier validValue(){
// require value >= _minimumBuy AND total deposit of msg.sender <= maximumBuyPrice
require ( (msg.value >= _minimumBuy) &&
( (deposit[msg.sender] + msg.value) <= _maximumBuy) );
_;
}
/**
*
*/
modifier isTradable(){
require(tradable == true || msg.sender == owner);
_;
}
/// @dev Fallback function allows to buy ether.
function()
public
payable {
buyGifto();
}
/// @dev buy function allows to buy ether. for using optional data
function buyGifto()
public
payable
onSale
validValue
validInvestor {
uint256 requestedUnits = (msg.value * _originalBuyPrice) / 10**18;
require(balances[owner] >= requestedUnits);
// prepare transfer data
balances[owner] -= requestedUnits;
balances[msg.sender] += requestedUnits;
// increase total deposit amount
deposit[msg.sender] += msg.value;
// check total and auto turnOffSale
totalTokenSold += requestedUnits;
if (totalTokenSold >= _icoSupply){
_selling = false;
}
// submit transfer
Transfer(owner, msg.sender, requestedUnits);
owner.transfer(msg.value);
}
/// @dev Constructor
function Gifto()
public {
owner = msg.sender;
setBuyPrice(_originalBuyPrice);
balances[owner] = _totalSupply;
Transfer(0x0, owner, _totalSupply);
}
/// @dev Gets totalSupply
/// @return Total supply
function totalSupply()
public
constant
returns (uint256) {
return _totalSupply;
}
/// @dev Enables sale
function turnOnSale() onlyOwner
public {
_selling = true;
}
/// @dev Disables sale
function turnOffSale() onlyOwner
public {
_selling = false;
}
function turnOnTradable()
public
onlyOwner{
tradable = true;
}
/// @dev set new icoPercent
/// @param newIcoPercent new value of icoPercent
function setIcoPercent(uint256 newIcoPercent)
public
onlyOwner {
_icoPercent = newIcoPercent;
_icoSupply = _totalSupply * _icoPercent / 100;
}
/// @dev set new _maximumBuy
/// @param newMaximumBuy new value of _maximumBuy
function setMaximumBuy(uint256 newMaximumBuy)
public
onlyOwner {
_maximumBuy = newMaximumBuy;
}
/// @dev Updates buy price (owner ONLY)
/// @param newBuyPrice New buy price (in unit)
function setBuyPrice(uint256 newBuyPrice)
onlyOwner
public {
require(newBuyPrice>0);
_originalBuyPrice = newBuyPrice; // 3000 Gifto = 3000 00000 unit
// control _maximumBuy_USD = 10,000 USD, Gifto price is 0.1USD
// maximumBuy_Gifto = 100,000 Gifto = 100,000,00000 unit
// 3000 Gifto = 1ETH => maximumETH = 100,000,00000 / _originalBuyPrice
// 100,000,00000/3000 0000 ~ 33ETH => change to wei
_maximumBuy = 10**18 * 10000000000 /_originalBuyPrice;
}
/// @dev Gets account's balance
/// @param _addr Address of the account
/// @return Account balance
function balanceOf(address _addr)
public
constant
returns (uint256) {
return balances[_addr];
}
/// @dev check address is approved investor
/// @param _addr address
function isApprovedInvestor(address _addr)
public
constant
returns (bool) {
return approvedInvestorList[_addr];
}
/// @dev get ETH deposit
/// @param _addr address get deposit
/// @return amount deposit of an buyer
function getDeposit(address _addr)
public
constant
returns(uint256){
return deposit[_addr];
}
/// @dev Adds list of new investors to the investors list and approve all
/// @param newInvestorList Array of new investors addresses to be added
function addInvestorList(address[] newInvestorList)
onlyOwner
public {
for (uint256 i = 0; i < newInvestorList.length; i++){
approvedInvestorList[newInvestorList[i]] = true;
}
}
/// @dev Removes list of investors from list
/// @param investorList Array of addresses of investors to be removed
function removeInvestorList(address[] investorList)
onlyOwner
public {
for (uint256 i = 0; i < investorList.length; i++){
approvedInvestorList[investorList[i]] = false;
}
}
/// @dev Transfers the balance from msg.sender to an account
/// @param _to Recipient address
/// @param _amount Transfered amount in unit
/// @return Transfer status
function transfer(address _to, uint256 _amount)
public
isTradable
returns (bool) {
// if sender's balance has enough unit and amount >= 0,
// and the sum is not overflow,
// then do transfer
if ( (balances[msg.sender] >= _amount) &&
(_amount >= 0) &&
(balances[_to] + _amount > balances[_to]) ) {
balances[msg.sender] -= _amount;
balances[_to] += _amount;
Transfer(msg.sender, _to, _amount);
return true;
} else {
return false;
}
}
// Send _value amount of tokens from address _from to address _to
// The transferFrom method is used for a withdraw workflow, allowing contracts to send
// tokens on your behalf, for example to "deposit" to a contract address and/or to charge
// fees in sub-currencies; the command should fail unless the _from account has
// deliberately authorized the sender of the message via some mechanism; we propose
// these standardized APIs for approval:
function transferFrom(
address _from,
address _to,
uint256 _amount
)
public
isTradable
returns (bool success) {
if (balances[_from] >= _amount
&& allowed[_from][msg.sender] >= _amount
&& _amount > 0
&& balances[_to] + _amount > balances[_to]) {
balances[_from] -= _amount;
allowed[_from][msg.sender] -= _amount;
balances[_to] += _amount;
Transfer(_from, _to, _amount);
return true;
} else {
return false;
}
}
// Allow _spender to withdraw from your account, multiple times, up to the _value amount.
// If this function is called again it overwrites the current allowance with _value.
function approve(address _spender, uint256 _amount)
public
isTradable
returns (bool success) {
allowed[msg.sender][_spender] = _amount;
Approval(msg.sender, _spender, _amount);
return true;
}
// get allowance
function allowance(address _owner, address _spender)
public
constant
returns (uint256 remaining) {
return allowed[_owner][_spender];
}
/// @dev Withdraws Ether in contract (Owner only)
/// @return Status of withdrawal
function withdraw() onlyOwner
public
returns (bool) {
return owner.send(this.balance);
}
} | setBuyPrice | function setBuyPrice(uint256 newBuyPrice)
onlyOwner
public {
require(newBuyPrice>0);
_originalBuyPrice = newBuyPrice; // 3000 Gifto = 3000 00000 unit
// control _maximumBuy_USD = 10,000 USD, Gifto price is 0.1USD
// maximumBuy_Gifto = 100,000 Gifto = 100,000,00000 unit
// 3000 Gifto = 1ETH => maximumETH = 100,000,00000 / _originalBuyPrice
// 100,000,00000/3000 0000 ~ 33ETH => change to wei
_maximumBuy = 10**18 * 10000000000 /_originalBuyPrice;
}
| /// @dev Updates buy price (owner ONLY)
/// @param newBuyPrice New buy price (in unit) | NatSpecSingleLine | v0.4.18+commit.9cf6e910 | bzzr://891e8485538f16f2fa5b9af11f8c795bc62d51fb6455063a6ee3652fa7680f20 | {
"func_code_index": [
4976,
5518
]
} | 3,522 |
|||
MultiSigWallet | MultiSigWallet.sol | 0x615ed6779507f223d04722d43ccc0cd871964e2a | Solidity | Gifto | contract Gifto is ERC20Interface {
uint256 public constant decimals = 5;
string public constant symbol = "GTO";
string public constant name = "Gifto";
bool public _selling = true;//initial selling
uint256 public _totalSupply = 10 ** 14; // total supply is 10^14 unit, equivalent to 10^9 Gifto
uint256 public _originalBuyPrice = 43 * 10**7; // original buy 1ETH = 4300 Gifto = 43 * 10**7 unit
// Owner of this contract
address public owner;
// Balances Gifto for each account
mapping(address => uint256) private balances;
// Owner of account approves the transfer of an amount to another account
mapping(address => mapping (address => uint256)) private allowed;
// List of approved investors
mapping(address => bool) private approvedInvestorList;
// deposit
mapping(address => uint256) private deposit;
// icoPercent
uint256 public _icoPercent = 10;
// _icoSupply is the avalable unit. Initially, it is _totalSupply
uint256 public _icoSupply = _totalSupply * _icoPercent / 100;
// minimum buy 0.3 ETH
uint256 public _minimumBuy = 3 * 10 ** 17;
// maximum buy 25 ETH
uint256 public _maximumBuy = 25 * 10 ** 18;
// totalTokenSold
uint256 public totalTokenSold = 0;
// tradable
bool public tradable = false;
/**
* Functions with this modifier can only be executed by the owner
*/
modifier onlyOwner() {
require(msg.sender == owner);
_;
}
/**
* Functions with this modifier check on sale status
* Only allow sale if _selling is on
*/
modifier onSale() {
require(_selling);
_;
}
/**
* Functions with this modifier check the validity of address is investor
*/
modifier validInvestor() {
require(approvedInvestorList[msg.sender]);
_;
}
/**
* Functions with this modifier check the validity of msg value
* value must greater than equal minimumBuyPrice
* total deposit must less than equal maximumBuyPrice
*/
modifier validValue(){
// require value >= _minimumBuy AND total deposit of msg.sender <= maximumBuyPrice
require ( (msg.value >= _minimumBuy) &&
( (deposit[msg.sender] + msg.value) <= _maximumBuy) );
_;
}
/**
*
*/
modifier isTradable(){
require(tradable == true || msg.sender == owner);
_;
}
/// @dev Fallback function allows to buy ether.
function()
public
payable {
buyGifto();
}
/// @dev buy function allows to buy ether. for using optional data
function buyGifto()
public
payable
onSale
validValue
validInvestor {
uint256 requestedUnits = (msg.value * _originalBuyPrice) / 10**18;
require(balances[owner] >= requestedUnits);
// prepare transfer data
balances[owner] -= requestedUnits;
balances[msg.sender] += requestedUnits;
// increase total deposit amount
deposit[msg.sender] += msg.value;
// check total and auto turnOffSale
totalTokenSold += requestedUnits;
if (totalTokenSold >= _icoSupply){
_selling = false;
}
// submit transfer
Transfer(owner, msg.sender, requestedUnits);
owner.transfer(msg.value);
}
/// @dev Constructor
function Gifto()
public {
owner = msg.sender;
setBuyPrice(_originalBuyPrice);
balances[owner] = _totalSupply;
Transfer(0x0, owner, _totalSupply);
}
/// @dev Gets totalSupply
/// @return Total supply
function totalSupply()
public
constant
returns (uint256) {
return _totalSupply;
}
/// @dev Enables sale
function turnOnSale() onlyOwner
public {
_selling = true;
}
/// @dev Disables sale
function turnOffSale() onlyOwner
public {
_selling = false;
}
function turnOnTradable()
public
onlyOwner{
tradable = true;
}
/// @dev set new icoPercent
/// @param newIcoPercent new value of icoPercent
function setIcoPercent(uint256 newIcoPercent)
public
onlyOwner {
_icoPercent = newIcoPercent;
_icoSupply = _totalSupply * _icoPercent / 100;
}
/// @dev set new _maximumBuy
/// @param newMaximumBuy new value of _maximumBuy
function setMaximumBuy(uint256 newMaximumBuy)
public
onlyOwner {
_maximumBuy = newMaximumBuy;
}
/// @dev Updates buy price (owner ONLY)
/// @param newBuyPrice New buy price (in unit)
function setBuyPrice(uint256 newBuyPrice)
onlyOwner
public {
require(newBuyPrice>0);
_originalBuyPrice = newBuyPrice; // 3000 Gifto = 3000 00000 unit
// control _maximumBuy_USD = 10,000 USD, Gifto price is 0.1USD
// maximumBuy_Gifto = 100,000 Gifto = 100,000,00000 unit
// 3000 Gifto = 1ETH => maximumETH = 100,000,00000 / _originalBuyPrice
// 100,000,00000/3000 0000 ~ 33ETH => change to wei
_maximumBuy = 10**18 * 10000000000 /_originalBuyPrice;
}
/// @dev Gets account's balance
/// @param _addr Address of the account
/// @return Account balance
function balanceOf(address _addr)
public
constant
returns (uint256) {
return balances[_addr];
}
/// @dev check address is approved investor
/// @param _addr address
function isApprovedInvestor(address _addr)
public
constant
returns (bool) {
return approvedInvestorList[_addr];
}
/// @dev get ETH deposit
/// @param _addr address get deposit
/// @return amount deposit of an buyer
function getDeposit(address _addr)
public
constant
returns(uint256){
return deposit[_addr];
}
/// @dev Adds list of new investors to the investors list and approve all
/// @param newInvestorList Array of new investors addresses to be added
function addInvestorList(address[] newInvestorList)
onlyOwner
public {
for (uint256 i = 0; i < newInvestorList.length; i++){
approvedInvestorList[newInvestorList[i]] = true;
}
}
/// @dev Removes list of investors from list
/// @param investorList Array of addresses of investors to be removed
function removeInvestorList(address[] investorList)
onlyOwner
public {
for (uint256 i = 0; i < investorList.length; i++){
approvedInvestorList[investorList[i]] = false;
}
}
/// @dev Transfers the balance from msg.sender to an account
/// @param _to Recipient address
/// @param _amount Transfered amount in unit
/// @return Transfer status
function transfer(address _to, uint256 _amount)
public
isTradable
returns (bool) {
// if sender's balance has enough unit and amount >= 0,
// and the sum is not overflow,
// then do transfer
if ( (balances[msg.sender] >= _amount) &&
(_amount >= 0) &&
(balances[_to] + _amount > balances[_to]) ) {
balances[msg.sender] -= _amount;
balances[_to] += _amount;
Transfer(msg.sender, _to, _amount);
return true;
} else {
return false;
}
}
// Send _value amount of tokens from address _from to address _to
// The transferFrom method is used for a withdraw workflow, allowing contracts to send
// tokens on your behalf, for example to "deposit" to a contract address and/or to charge
// fees in sub-currencies; the command should fail unless the _from account has
// deliberately authorized the sender of the message via some mechanism; we propose
// these standardized APIs for approval:
function transferFrom(
address _from,
address _to,
uint256 _amount
)
public
isTradable
returns (bool success) {
if (balances[_from] >= _amount
&& allowed[_from][msg.sender] >= _amount
&& _amount > 0
&& balances[_to] + _amount > balances[_to]) {
balances[_from] -= _amount;
allowed[_from][msg.sender] -= _amount;
balances[_to] += _amount;
Transfer(_from, _to, _amount);
return true;
} else {
return false;
}
}
// Allow _spender to withdraw from your account, multiple times, up to the _value amount.
// If this function is called again it overwrites the current allowance with _value.
function approve(address _spender, uint256 _amount)
public
isTradable
returns (bool success) {
allowed[msg.sender][_spender] = _amount;
Approval(msg.sender, _spender, _amount);
return true;
}
// get allowance
function allowance(address _owner, address _spender)
public
constant
returns (uint256 remaining) {
return allowed[_owner][_spender];
}
/// @dev Withdraws Ether in contract (Owner only)
/// @return Status of withdrawal
function withdraw() onlyOwner
public
returns (bool) {
return owner.send(this.balance);
}
} | balanceOf | function balanceOf(address _addr)
public
constant
returns (uint256) {
return balances[_addr];
}
| /// @dev Gets account's balance
/// @param _addr Address of the account
/// @return Account balance | NatSpecSingleLine | v0.4.18+commit.9cf6e910 | bzzr://891e8485538f16f2fa5b9af11f8c795bc62d51fb6455063a6ee3652fa7680f20 | {
"func_code_index": [
5644,
5787
]
} | 3,523 |
|||
MultiSigWallet | MultiSigWallet.sol | 0x615ed6779507f223d04722d43ccc0cd871964e2a | Solidity | Gifto | contract Gifto is ERC20Interface {
uint256 public constant decimals = 5;
string public constant symbol = "GTO";
string public constant name = "Gifto";
bool public _selling = true;//initial selling
uint256 public _totalSupply = 10 ** 14; // total supply is 10^14 unit, equivalent to 10^9 Gifto
uint256 public _originalBuyPrice = 43 * 10**7; // original buy 1ETH = 4300 Gifto = 43 * 10**7 unit
// Owner of this contract
address public owner;
// Balances Gifto for each account
mapping(address => uint256) private balances;
// Owner of account approves the transfer of an amount to another account
mapping(address => mapping (address => uint256)) private allowed;
// List of approved investors
mapping(address => bool) private approvedInvestorList;
// deposit
mapping(address => uint256) private deposit;
// icoPercent
uint256 public _icoPercent = 10;
// _icoSupply is the avalable unit. Initially, it is _totalSupply
uint256 public _icoSupply = _totalSupply * _icoPercent / 100;
// minimum buy 0.3 ETH
uint256 public _minimumBuy = 3 * 10 ** 17;
// maximum buy 25 ETH
uint256 public _maximumBuy = 25 * 10 ** 18;
// totalTokenSold
uint256 public totalTokenSold = 0;
// tradable
bool public tradable = false;
/**
* Functions with this modifier can only be executed by the owner
*/
modifier onlyOwner() {
require(msg.sender == owner);
_;
}
/**
* Functions with this modifier check on sale status
* Only allow sale if _selling is on
*/
modifier onSale() {
require(_selling);
_;
}
/**
* Functions with this modifier check the validity of address is investor
*/
modifier validInvestor() {
require(approvedInvestorList[msg.sender]);
_;
}
/**
* Functions with this modifier check the validity of msg value
* value must greater than equal minimumBuyPrice
* total deposit must less than equal maximumBuyPrice
*/
modifier validValue(){
// require value >= _minimumBuy AND total deposit of msg.sender <= maximumBuyPrice
require ( (msg.value >= _minimumBuy) &&
( (deposit[msg.sender] + msg.value) <= _maximumBuy) );
_;
}
/**
*
*/
modifier isTradable(){
require(tradable == true || msg.sender == owner);
_;
}
/// @dev Fallback function allows to buy ether.
function()
public
payable {
buyGifto();
}
/// @dev buy function allows to buy ether. for using optional data
function buyGifto()
public
payable
onSale
validValue
validInvestor {
uint256 requestedUnits = (msg.value * _originalBuyPrice) / 10**18;
require(balances[owner] >= requestedUnits);
// prepare transfer data
balances[owner] -= requestedUnits;
balances[msg.sender] += requestedUnits;
// increase total deposit amount
deposit[msg.sender] += msg.value;
// check total and auto turnOffSale
totalTokenSold += requestedUnits;
if (totalTokenSold >= _icoSupply){
_selling = false;
}
// submit transfer
Transfer(owner, msg.sender, requestedUnits);
owner.transfer(msg.value);
}
/// @dev Constructor
function Gifto()
public {
owner = msg.sender;
setBuyPrice(_originalBuyPrice);
balances[owner] = _totalSupply;
Transfer(0x0, owner, _totalSupply);
}
/// @dev Gets totalSupply
/// @return Total supply
function totalSupply()
public
constant
returns (uint256) {
return _totalSupply;
}
/// @dev Enables sale
function turnOnSale() onlyOwner
public {
_selling = true;
}
/// @dev Disables sale
function turnOffSale() onlyOwner
public {
_selling = false;
}
function turnOnTradable()
public
onlyOwner{
tradable = true;
}
/// @dev set new icoPercent
/// @param newIcoPercent new value of icoPercent
function setIcoPercent(uint256 newIcoPercent)
public
onlyOwner {
_icoPercent = newIcoPercent;
_icoSupply = _totalSupply * _icoPercent / 100;
}
/// @dev set new _maximumBuy
/// @param newMaximumBuy new value of _maximumBuy
function setMaximumBuy(uint256 newMaximumBuy)
public
onlyOwner {
_maximumBuy = newMaximumBuy;
}
/// @dev Updates buy price (owner ONLY)
/// @param newBuyPrice New buy price (in unit)
function setBuyPrice(uint256 newBuyPrice)
onlyOwner
public {
require(newBuyPrice>0);
_originalBuyPrice = newBuyPrice; // 3000 Gifto = 3000 00000 unit
// control _maximumBuy_USD = 10,000 USD, Gifto price is 0.1USD
// maximumBuy_Gifto = 100,000 Gifto = 100,000,00000 unit
// 3000 Gifto = 1ETH => maximumETH = 100,000,00000 / _originalBuyPrice
// 100,000,00000/3000 0000 ~ 33ETH => change to wei
_maximumBuy = 10**18 * 10000000000 /_originalBuyPrice;
}
/// @dev Gets account's balance
/// @param _addr Address of the account
/// @return Account balance
function balanceOf(address _addr)
public
constant
returns (uint256) {
return balances[_addr];
}
/// @dev check address is approved investor
/// @param _addr address
function isApprovedInvestor(address _addr)
public
constant
returns (bool) {
return approvedInvestorList[_addr];
}
/// @dev get ETH deposit
/// @param _addr address get deposit
/// @return amount deposit of an buyer
function getDeposit(address _addr)
public
constant
returns(uint256){
return deposit[_addr];
}
/// @dev Adds list of new investors to the investors list and approve all
/// @param newInvestorList Array of new investors addresses to be added
function addInvestorList(address[] newInvestorList)
onlyOwner
public {
for (uint256 i = 0; i < newInvestorList.length; i++){
approvedInvestorList[newInvestorList[i]] = true;
}
}
/// @dev Removes list of investors from list
/// @param investorList Array of addresses of investors to be removed
function removeInvestorList(address[] investorList)
onlyOwner
public {
for (uint256 i = 0; i < investorList.length; i++){
approvedInvestorList[investorList[i]] = false;
}
}
/// @dev Transfers the balance from msg.sender to an account
/// @param _to Recipient address
/// @param _amount Transfered amount in unit
/// @return Transfer status
function transfer(address _to, uint256 _amount)
public
isTradable
returns (bool) {
// if sender's balance has enough unit and amount >= 0,
// and the sum is not overflow,
// then do transfer
if ( (balances[msg.sender] >= _amount) &&
(_amount >= 0) &&
(balances[_to] + _amount > balances[_to]) ) {
balances[msg.sender] -= _amount;
balances[_to] += _amount;
Transfer(msg.sender, _to, _amount);
return true;
} else {
return false;
}
}
// Send _value amount of tokens from address _from to address _to
// The transferFrom method is used for a withdraw workflow, allowing contracts to send
// tokens on your behalf, for example to "deposit" to a contract address and/or to charge
// fees in sub-currencies; the command should fail unless the _from account has
// deliberately authorized the sender of the message via some mechanism; we propose
// these standardized APIs for approval:
function transferFrom(
address _from,
address _to,
uint256 _amount
)
public
isTradable
returns (bool success) {
if (balances[_from] >= _amount
&& allowed[_from][msg.sender] >= _amount
&& _amount > 0
&& balances[_to] + _amount > balances[_to]) {
balances[_from] -= _amount;
allowed[_from][msg.sender] -= _amount;
balances[_to] += _amount;
Transfer(_from, _to, _amount);
return true;
} else {
return false;
}
}
// Allow _spender to withdraw from your account, multiple times, up to the _value amount.
// If this function is called again it overwrites the current allowance with _value.
function approve(address _spender, uint256 _amount)
public
isTradable
returns (bool success) {
allowed[msg.sender][_spender] = _amount;
Approval(msg.sender, _spender, _amount);
return true;
}
// get allowance
function allowance(address _owner, address _spender)
public
constant
returns (uint256 remaining) {
return allowed[_owner][_spender];
}
/// @dev Withdraws Ether in contract (Owner only)
/// @return Status of withdrawal
function withdraw() onlyOwner
public
returns (bool) {
return owner.send(this.balance);
}
} | isApprovedInvestor | function isApprovedInvestor(address _addr)
public
constant
returns (bool) {
return approvedInvestorList[_addr];
}
| /// @dev check address is approved investor
/// @param _addr address | NatSpecSingleLine | v0.4.18+commit.9cf6e910 | bzzr://891e8485538f16f2fa5b9af11f8c795bc62d51fb6455063a6ee3652fa7680f20 | {
"func_code_index": [
5873,
6032
]
} | 3,524 |
|||
MultiSigWallet | MultiSigWallet.sol | 0x615ed6779507f223d04722d43ccc0cd871964e2a | Solidity | Gifto | contract Gifto is ERC20Interface {
uint256 public constant decimals = 5;
string public constant symbol = "GTO";
string public constant name = "Gifto";
bool public _selling = true;//initial selling
uint256 public _totalSupply = 10 ** 14; // total supply is 10^14 unit, equivalent to 10^9 Gifto
uint256 public _originalBuyPrice = 43 * 10**7; // original buy 1ETH = 4300 Gifto = 43 * 10**7 unit
// Owner of this contract
address public owner;
// Balances Gifto for each account
mapping(address => uint256) private balances;
// Owner of account approves the transfer of an amount to another account
mapping(address => mapping (address => uint256)) private allowed;
// List of approved investors
mapping(address => bool) private approvedInvestorList;
// deposit
mapping(address => uint256) private deposit;
// icoPercent
uint256 public _icoPercent = 10;
// _icoSupply is the avalable unit. Initially, it is _totalSupply
uint256 public _icoSupply = _totalSupply * _icoPercent / 100;
// minimum buy 0.3 ETH
uint256 public _minimumBuy = 3 * 10 ** 17;
// maximum buy 25 ETH
uint256 public _maximumBuy = 25 * 10 ** 18;
// totalTokenSold
uint256 public totalTokenSold = 0;
// tradable
bool public tradable = false;
/**
* Functions with this modifier can only be executed by the owner
*/
modifier onlyOwner() {
require(msg.sender == owner);
_;
}
/**
* Functions with this modifier check on sale status
* Only allow sale if _selling is on
*/
modifier onSale() {
require(_selling);
_;
}
/**
* Functions with this modifier check the validity of address is investor
*/
modifier validInvestor() {
require(approvedInvestorList[msg.sender]);
_;
}
/**
* Functions with this modifier check the validity of msg value
* value must greater than equal minimumBuyPrice
* total deposit must less than equal maximumBuyPrice
*/
modifier validValue(){
// require value >= _minimumBuy AND total deposit of msg.sender <= maximumBuyPrice
require ( (msg.value >= _minimumBuy) &&
( (deposit[msg.sender] + msg.value) <= _maximumBuy) );
_;
}
/**
*
*/
modifier isTradable(){
require(tradable == true || msg.sender == owner);
_;
}
/// @dev Fallback function allows to buy ether.
function()
public
payable {
buyGifto();
}
/// @dev buy function allows to buy ether. for using optional data
function buyGifto()
public
payable
onSale
validValue
validInvestor {
uint256 requestedUnits = (msg.value * _originalBuyPrice) / 10**18;
require(balances[owner] >= requestedUnits);
// prepare transfer data
balances[owner] -= requestedUnits;
balances[msg.sender] += requestedUnits;
// increase total deposit amount
deposit[msg.sender] += msg.value;
// check total and auto turnOffSale
totalTokenSold += requestedUnits;
if (totalTokenSold >= _icoSupply){
_selling = false;
}
// submit transfer
Transfer(owner, msg.sender, requestedUnits);
owner.transfer(msg.value);
}
/// @dev Constructor
function Gifto()
public {
owner = msg.sender;
setBuyPrice(_originalBuyPrice);
balances[owner] = _totalSupply;
Transfer(0x0, owner, _totalSupply);
}
/// @dev Gets totalSupply
/// @return Total supply
function totalSupply()
public
constant
returns (uint256) {
return _totalSupply;
}
/// @dev Enables sale
function turnOnSale() onlyOwner
public {
_selling = true;
}
/// @dev Disables sale
function turnOffSale() onlyOwner
public {
_selling = false;
}
function turnOnTradable()
public
onlyOwner{
tradable = true;
}
/// @dev set new icoPercent
/// @param newIcoPercent new value of icoPercent
function setIcoPercent(uint256 newIcoPercent)
public
onlyOwner {
_icoPercent = newIcoPercent;
_icoSupply = _totalSupply * _icoPercent / 100;
}
/// @dev set new _maximumBuy
/// @param newMaximumBuy new value of _maximumBuy
function setMaximumBuy(uint256 newMaximumBuy)
public
onlyOwner {
_maximumBuy = newMaximumBuy;
}
/// @dev Updates buy price (owner ONLY)
/// @param newBuyPrice New buy price (in unit)
function setBuyPrice(uint256 newBuyPrice)
onlyOwner
public {
require(newBuyPrice>0);
_originalBuyPrice = newBuyPrice; // 3000 Gifto = 3000 00000 unit
// control _maximumBuy_USD = 10,000 USD, Gifto price is 0.1USD
// maximumBuy_Gifto = 100,000 Gifto = 100,000,00000 unit
// 3000 Gifto = 1ETH => maximumETH = 100,000,00000 / _originalBuyPrice
// 100,000,00000/3000 0000 ~ 33ETH => change to wei
_maximumBuy = 10**18 * 10000000000 /_originalBuyPrice;
}
/// @dev Gets account's balance
/// @param _addr Address of the account
/// @return Account balance
function balanceOf(address _addr)
public
constant
returns (uint256) {
return balances[_addr];
}
/// @dev check address is approved investor
/// @param _addr address
function isApprovedInvestor(address _addr)
public
constant
returns (bool) {
return approvedInvestorList[_addr];
}
/// @dev get ETH deposit
/// @param _addr address get deposit
/// @return amount deposit of an buyer
function getDeposit(address _addr)
public
constant
returns(uint256){
return deposit[_addr];
}
/// @dev Adds list of new investors to the investors list and approve all
/// @param newInvestorList Array of new investors addresses to be added
function addInvestorList(address[] newInvestorList)
onlyOwner
public {
for (uint256 i = 0; i < newInvestorList.length; i++){
approvedInvestorList[newInvestorList[i]] = true;
}
}
/// @dev Removes list of investors from list
/// @param investorList Array of addresses of investors to be removed
function removeInvestorList(address[] investorList)
onlyOwner
public {
for (uint256 i = 0; i < investorList.length; i++){
approvedInvestorList[investorList[i]] = false;
}
}
/// @dev Transfers the balance from msg.sender to an account
/// @param _to Recipient address
/// @param _amount Transfered amount in unit
/// @return Transfer status
function transfer(address _to, uint256 _amount)
public
isTradable
returns (bool) {
// if sender's balance has enough unit and amount >= 0,
// and the sum is not overflow,
// then do transfer
if ( (balances[msg.sender] >= _amount) &&
(_amount >= 0) &&
(balances[_to] + _amount > balances[_to]) ) {
balances[msg.sender] -= _amount;
balances[_to] += _amount;
Transfer(msg.sender, _to, _amount);
return true;
} else {
return false;
}
}
// Send _value amount of tokens from address _from to address _to
// The transferFrom method is used for a withdraw workflow, allowing contracts to send
// tokens on your behalf, for example to "deposit" to a contract address and/or to charge
// fees in sub-currencies; the command should fail unless the _from account has
// deliberately authorized the sender of the message via some mechanism; we propose
// these standardized APIs for approval:
function transferFrom(
address _from,
address _to,
uint256 _amount
)
public
isTradable
returns (bool success) {
if (balances[_from] >= _amount
&& allowed[_from][msg.sender] >= _amount
&& _amount > 0
&& balances[_to] + _amount > balances[_to]) {
balances[_from] -= _amount;
allowed[_from][msg.sender] -= _amount;
balances[_to] += _amount;
Transfer(_from, _to, _amount);
return true;
} else {
return false;
}
}
// Allow _spender to withdraw from your account, multiple times, up to the _value amount.
// If this function is called again it overwrites the current allowance with _value.
function approve(address _spender, uint256 _amount)
public
isTradable
returns (bool success) {
allowed[msg.sender][_spender] = _amount;
Approval(msg.sender, _spender, _amount);
return true;
}
// get allowance
function allowance(address _owner, address _spender)
public
constant
returns (uint256 remaining) {
return allowed[_owner][_spender];
}
/// @dev Withdraws Ether in contract (Owner only)
/// @return Status of withdrawal
function withdraw() onlyOwner
public
returns (bool) {
return owner.send(this.balance);
}
} | getDeposit | function getDeposit(address _addr)
public
constant
returns(uint256){
return deposit[_addr];
| /// @dev get ETH deposit
/// @param _addr address get deposit
/// @return amount deposit of an buyer | NatSpecSingleLine | v0.4.18+commit.9cf6e910 | bzzr://891e8485538f16f2fa5b9af11f8c795bc62d51fb6455063a6ee3652fa7680f20 | {
"func_code_index": [
6155,
6290
]
} | 3,525 |
|||
MultiSigWallet | MultiSigWallet.sol | 0x615ed6779507f223d04722d43ccc0cd871964e2a | Solidity | Gifto | contract Gifto is ERC20Interface {
uint256 public constant decimals = 5;
string public constant symbol = "GTO";
string public constant name = "Gifto";
bool public _selling = true;//initial selling
uint256 public _totalSupply = 10 ** 14; // total supply is 10^14 unit, equivalent to 10^9 Gifto
uint256 public _originalBuyPrice = 43 * 10**7; // original buy 1ETH = 4300 Gifto = 43 * 10**7 unit
// Owner of this contract
address public owner;
// Balances Gifto for each account
mapping(address => uint256) private balances;
// Owner of account approves the transfer of an amount to another account
mapping(address => mapping (address => uint256)) private allowed;
// List of approved investors
mapping(address => bool) private approvedInvestorList;
// deposit
mapping(address => uint256) private deposit;
// icoPercent
uint256 public _icoPercent = 10;
// _icoSupply is the avalable unit. Initially, it is _totalSupply
uint256 public _icoSupply = _totalSupply * _icoPercent / 100;
// minimum buy 0.3 ETH
uint256 public _minimumBuy = 3 * 10 ** 17;
// maximum buy 25 ETH
uint256 public _maximumBuy = 25 * 10 ** 18;
// totalTokenSold
uint256 public totalTokenSold = 0;
// tradable
bool public tradable = false;
/**
* Functions with this modifier can only be executed by the owner
*/
modifier onlyOwner() {
require(msg.sender == owner);
_;
}
/**
* Functions with this modifier check on sale status
* Only allow sale if _selling is on
*/
modifier onSale() {
require(_selling);
_;
}
/**
* Functions with this modifier check the validity of address is investor
*/
modifier validInvestor() {
require(approvedInvestorList[msg.sender]);
_;
}
/**
* Functions with this modifier check the validity of msg value
* value must greater than equal minimumBuyPrice
* total deposit must less than equal maximumBuyPrice
*/
modifier validValue(){
// require value >= _minimumBuy AND total deposit of msg.sender <= maximumBuyPrice
require ( (msg.value >= _minimumBuy) &&
( (deposit[msg.sender] + msg.value) <= _maximumBuy) );
_;
}
/**
*
*/
modifier isTradable(){
require(tradable == true || msg.sender == owner);
_;
}
/// @dev Fallback function allows to buy ether.
function()
public
payable {
buyGifto();
}
/// @dev buy function allows to buy ether. for using optional data
function buyGifto()
public
payable
onSale
validValue
validInvestor {
uint256 requestedUnits = (msg.value * _originalBuyPrice) / 10**18;
require(balances[owner] >= requestedUnits);
// prepare transfer data
balances[owner] -= requestedUnits;
balances[msg.sender] += requestedUnits;
// increase total deposit amount
deposit[msg.sender] += msg.value;
// check total and auto turnOffSale
totalTokenSold += requestedUnits;
if (totalTokenSold >= _icoSupply){
_selling = false;
}
// submit transfer
Transfer(owner, msg.sender, requestedUnits);
owner.transfer(msg.value);
}
/// @dev Constructor
function Gifto()
public {
owner = msg.sender;
setBuyPrice(_originalBuyPrice);
balances[owner] = _totalSupply;
Transfer(0x0, owner, _totalSupply);
}
/// @dev Gets totalSupply
/// @return Total supply
function totalSupply()
public
constant
returns (uint256) {
return _totalSupply;
}
/// @dev Enables sale
function turnOnSale() onlyOwner
public {
_selling = true;
}
/// @dev Disables sale
function turnOffSale() onlyOwner
public {
_selling = false;
}
function turnOnTradable()
public
onlyOwner{
tradable = true;
}
/// @dev set new icoPercent
/// @param newIcoPercent new value of icoPercent
function setIcoPercent(uint256 newIcoPercent)
public
onlyOwner {
_icoPercent = newIcoPercent;
_icoSupply = _totalSupply * _icoPercent / 100;
}
/// @dev set new _maximumBuy
/// @param newMaximumBuy new value of _maximumBuy
function setMaximumBuy(uint256 newMaximumBuy)
public
onlyOwner {
_maximumBuy = newMaximumBuy;
}
/// @dev Updates buy price (owner ONLY)
/// @param newBuyPrice New buy price (in unit)
function setBuyPrice(uint256 newBuyPrice)
onlyOwner
public {
require(newBuyPrice>0);
_originalBuyPrice = newBuyPrice; // 3000 Gifto = 3000 00000 unit
// control _maximumBuy_USD = 10,000 USD, Gifto price is 0.1USD
// maximumBuy_Gifto = 100,000 Gifto = 100,000,00000 unit
// 3000 Gifto = 1ETH => maximumETH = 100,000,00000 / _originalBuyPrice
// 100,000,00000/3000 0000 ~ 33ETH => change to wei
_maximumBuy = 10**18 * 10000000000 /_originalBuyPrice;
}
/// @dev Gets account's balance
/// @param _addr Address of the account
/// @return Account balance
function balanceOf(address _addr)
public
constant
returns (uint256) {
return balances[_addr];
}
/// @dev check address is approved investor
/// @param _addr address
function isApprovedInvestor(address _addr)
public
constant
returns (bool) {
return approvedInvestorList[_addr];
}
/// @dev get ETH deposit
/// @param _addr address get deposit
/// @return amount deposit of an buyer
function getDeposit(address _addr)
public
constant
returns(uint256){
return deposit[_addr];
}
/// @dev Adds list of new investors to the investors list and approve all
/// @param newInvestorList Array of new investors addresses to be added
function addInvestorList(address[] newInvestorList)
onlyOwner
public {
for (uint256 i = 0; i < newInvestorList.length; i++){
approvedInvestorList[newInvestorList[i]] = true;
}
}
/// @dev Removes list of investors from list
/// @param investorList Array of addresses of investors to be removed
function removeInvestorList(address[] investorList)
onlyOwner
public {
for (uint256 i = 0; i < investorList.length; i++){
approvedInvestorList[investorList[i]] = false;
}
}
/// @dev Transfers the balance from msg.sender to an account
/// @param _to Recipient address
/// @param _amount Transfered amount in unit
/// @return Transfer status
function transfer(address _to, uint256 _amount)
public
isTradable
returns (bool) {
// if sender's balance has enough unit and amount >= 0,
// and the sum is not overflow,
// then do transfer
if ( (balances[msg.sender] >= _amount) &&
(_amount >= 0) &&
(balances[_to] + _amount > balances[_to]) ) {
balances[msg.sender] -= _amount;
balances[_to] += _amount;
Transfer(msg.sender, _to, _amount);
return true;
} else {
return false;
}
}
// Send _value amount of tokens from address _from to address _to
// The transferFrom method is used for a withdraw workflow, allowing contracts to send
// tokens on your behalf, for example to "deposit" to a contract address and/or to charge
// fees in sub-currencies; the command should fail unless the _from account has
// deliberately authorized the sender of the message via some mechanism; we propose
// these standardized APIs for approval:
function transferFrom(
address _from,
address _to,
uint256 _amount
)
public
isTradable
returns (bool success) {
if (balances[_from] >= _amount
&& allowed[_from][msg.sender] >= _amount
&& _amount > 0
&& balances[_to] + _amount > balances[_to]) {
balances[_from] -= _amount;
allowed[_from][msg.sender] -= _amount;
balances[_to] += _amount;
Transfer(_from, _to, _amount);
return true;
} else {
return false;
}
}
// Allow _spender to withdraw from your account, multiple times, up to the _value amount.
// If this function is called again it overwrites the current allowance with _value.
function approve(address _spender, uint256 _amount)
public
isTradable
returns (bool success) {
allowed[msg.sender][_spender] = _amount;
Approval(msg.sender, _spender, _amount);
return true;
}
// get allowance
function allowance(address _owner, address _spender)
public
constant
returns (uint256 remaining) {
return allowed[_owner][_spender];
}
/// @dev Withdraws Ether in contract (Owner only)
/// @return Status of withdrawal
function withdraw() onlyOwner
public
returns (bool) {
return owner.send(this.balance);
}
} | addInvestorList | function addInvestorList(address[] newInvestorList)
onlyOwner
public {
for (uint256 i = 0; i < newInvestorList.length; i++){
approvedInvestorList[newInvestorList[i]] = true;
}
}
| /// @dev Adds list of new investors to the investors list and approve all
/// @param newInvestorList Array of new investors addresses to be added | NatSpecSingleLine | v0.4.18+commit.9cf6e910 | bzzr://891e8485538f16f2fa5b9af11f8c795bc62d51fb6455063a6ee3652fa7680f20 | {
"func_code_index": [
6453,
6689
]
} | 3,526 |
|||
MultiSigWallet | MultiSigWallet.sol | 0x615ed6779507f223d04722d43ccc0cd871964e2a | Solidity | Gifto | contract Gifto is ERC20Interface {
uint256 public constant decimals = 5;
string public constant symbol = "GTO";
string public constant name = "Gifto";
bool public _selling = true;//initial selling
uint256 public _totalSupply = 10 ** 14; // total supply is 10^14 unit, equivalent to 10^9 Gifto
uint256 public _originalBuyPrice = 43 * 10**7; // original buy 1ETH = 4300 Gifto = 43 * 10**7 unit
// Owner of this contract
address public owner;
// Balances Gifto for each account
mapping(address => uint256) private balances;
// Owner of account approves the transfer of an amount to another account
mapping(address => mapping (address => uint256)) private allowed;
// List of approved investors
mapping(address => bool) private approvedInvestorList;
// deposit
mapping(address => uint256) private deposit;
// icoPercent
uint256 public _icoPercent = 10;
// _icoSupply is the avalable unit. Initially, it is _totalSupply
uint256 public _icoSupply = _totalSupply * _icoPercent / 100;
// minimum buy 0.3 ETH
uint256 public _minimumBuy = 3 * 10 ** 17;
// maximum buy 25 ETH
uint256 public _maximumBuy = 25 * 10 ** 18;
// totalTokenSold
uint256 public totalTokenSold = 0;
// tradable
bool public tradable = false;
/**
* Functions with this modifier can only be executed by the owner
*/
modifier onlyOwner() {
require(msg.sender == owner);
_;
}
/**
* Functions with this modifier check on sale status
* Only allow sale if _selling is on
*/
modifier onSale() {
require(_selling);
_;
}
/**
* Functions with this modifier check the validity of address is investor
*/
modifier validInvestor() {
require(approvedInvestorList[msg.sender]);
_;
}
/**
* Functions with this modifier check the validity of msg value
* value must greater than equal minimumBuyPrice
* total deposit must less than equal maximumBuyPrice
*/
modifier validValue(){
// require value >= _minimumBuy AND total deposit of msg.sender <= maximumBuyPrice
require ( (msg.value >= _minimumBuy) &&
( (deposit[msg.sender] + msg.value) <= _maximumBuy) );
_;
}
/**
*
*/
modifier isTradable(){
require(tradable == true || msg.sender == owner);
_;
}
/// @dev Fallback function allows to buy ether.
function()
public
payable {
buyGifto();
}
/// @dev buy function allows to buy ether. for using optional data
function buyGifto()
public
payable
onSale
validValue
validInvestor {
uint256 requestedUnits = (msg.value * _originalBuyPrice) / 10**18;
require(balances[owner] >= requestedUnits);
// prepare transfer data
balances[owner] -= requestedUnits;
balances[msg.sender] += requestedUnits;
// increase total deposit amount
deposit[msg.sender] += msg.value;
// check total and auto turnOffSale
totalTokenSold += requestedUnits;
if (totalTokenSold >= _icoSupply){
_selling = false;
}
// submit transfer
Transfer(owner, msg.sender, requestedUnits);
owner.transfer(msg.value);
}
/// @dev Constructor
function Gifto()
public {
owner = msg.sender;
setBuyPrice(_originalBuyPrice);
balances[owner] = _totalSupply;
Transfer(0x0, owner, _totalSupply);
}
/// @dev Gets totalSupply
/// @return Total supply
function totalSupply()
public
constant
returns (uint256) {
return _totalSupply;
}
/// @dev Enables sale
function turnOnSale() onlyOwner
public {
_selling = true;
}
/// @dev Disables sale
function turnOffSale() onlyOwner
public {
_selling = false;
}
function turnOnTradable()
public
onlyOwner{
tradable = true;
}
/// @dev set new icoPercent
/// @param newIcoPercent new value of icoPercent
function setIcoPercent(uint256 newIcoPercent)
public
onlyOwner {
_icoPercent = newIcoPercent;
_icoSupply = _totalSupply * _icoPercent / 100;
}
/// @dev set new _maximumBuy
/// @param newMaximumBuy new value of _maximumBuy
function setMaximumBuy(uint256 newMaximumBuy)
public
onlyOwner {
_maximumBuy = newMaximumBuy;
}
/// @dev Updates buy price (owner ONLY)
/// @param newBuyPrice New buy price (in unit)
function setBuyPrice(uint256 newBuyPrice)
onlyOwner
public {
require(newBuyPrice>0);
_originalBuyPrice = newBuyPrice; // 3000 Gifto = 3000 00000 unit
// control _maximumBuy_USD = 10,000 USD, Gifto price is 0.1USD
// maximumBuy_Gifto = 100,000 Gifto = 100,000,00000 unit
// 3000 Gifto = 1ETH => maximumETH = 100,000,00000 / _originalBuyPrice
// 100,000,00000/3000 0000 ~ 33ETH => change to wei
_maximumBuy = 10**18 * 10000000000 /_originalBuyPrice;
}
/// @dev Gets account's balance
/// @param _addr Address of the account
/// @return Account balance
function balanceOf(address _addr)
public
constant
returns (uint256) {
return balances[_addr];
}
/// @dev check address is approved investor
/// @param _addr address
function isApprovedInvestor(address _addr)
public
constant
returns (bool) {
return approvedInvestorList[_addr];
}
/// @dev get ETH deposit
/// @param _addr address get deposit
/// @return amount deposit of an buyer
function getDeposit(address _addr)
public
constant
returns(uint256){
return deposit[_addr];
}
/// @dev Adds list of new investors to the investors list and approve all
/// @param newInvestorList Array of new investors addresses to be added
function addInvestorList(address[] newInvestorList)
onlyOwner
public {
for (uint256 i = 0; i < newInvestorList.length; i++){
approvedInvestorList[newInvestorList[i]] = true;
}
}
/// @dev Removes list of investors from list
/// @param investorList Array of addresses of investors to be removed
function removeInvestorList(address[] investorList)
onlyOwner
public {
for (uint256 i = 0; i < investorList.length; i++){
approvedInvestorList[investorList[i]] = false;
}
}
/// @dev Transfers the balance from msg.sender to an account
/// @param _to Recipient address
/// @param _amount Transfered amount in unit
/// @return Transfer status
function transfer(address _to, uint256 _amount)
public
isTradable
returns (bool) {
// if sender's balance has enough unit and amount >= 0,
// and the sum is not overflow,
// then do transfer
if ( (balances[msg.sender] >= _amount) &&
(_amount >= 0) &&
(balances[_to] + _amount > balances[_to]) ) {
balances[msg.sender] -= _amount;
balances[_to] += _amount;
Transfer(msg.sender, _to, _amount);
return true;
} else {
return false;
}
}
// Send _value amount of tokens from address _from to address _to
// The transferFrom method is used for a withdraw workflow, allowing contracts to send
// tokens on your behalf, for example to "deposit" to a contract address and/or to charge
// fees in sub-currencies; the command should fail unless the _from account has
// deliberately authorized the sender of the message via some mechanism; we propose
// these standardized APIs for approval:
function transferFrom(
address _from,
address _to,
uint256 _amount
)
public
isTradable
returns (bool success) {
if (balances[_from] >= _amount
&& allowed[_from][msg.sender] >= _amount
&& _amount > 0
&& balances[_to] + _amount > balances[_to]) {
balances[_from] -= _amount;
allowed[_from][msg.sender] -= _amount;
balances[_to] += _amount;
Transfer(_from, _to, _amount);
return true;
} else {
return false;
}
}
// Allow _spender to withdraw from your account, multiple times, up to the _value amount.
// If this function is called again it overwrites the current allowance with _value.
function approve(address _spender, uint256 _amount)
public
isTradable
returns (bool success) {
allowed[msg.sender][_spender] = _amount;
Approval(msg.sender, _spender, _amount);
return true;
}
// get allowance
function allowance(address _owner, address _spender)
public
constant
returns (uint256 remaining) {
return allowed[_owner][_spender];
}
/// @dev Withdraws Ether in contract (Owner only)
/// @return Status of withdrawal
function withdraw() onlyOwner
public
returns (bool) {
return owner.send(this.balance);
}
} | removeInvestorList | function removeInvestorList(address[] investorList)
onlyOwner
public {
for (uint256 i = 0; i < investorList.length; i++){
approvedInvestorList[investorList[i]] = false;
}
}
| /// @dev Removes list of investors from list
/// @param investorList Array of addresses of investors to be removed | NatSpecSingleLine | v0.4.18+commit.9cf6e910 | bzzr://891e8485538f16f2fa5b9af11f8c795bc62d51fb6455063a6ee3652fa7680f20 | {
"func_code_index": [
6817,
7048
]
} | 3,527 |
|||
MultiSigWallet | MultiSigWallet.sol | 0x615ed6779507f223d04722d43ccc0cd871964e2a | Solidity | Gifto | contract Gifto is ERC20Interface {
uint256 public constant decimals = 5;
string public constant symbol = "GTO";
string public constant name = "Gifto";
bool public _selling = true;//initial selling
uint256 public _totalSupply = 10 ** 14; // total supply is 10^14 unit, equivalent to 10^9 Gifto
uint256 public _originalBuyPrice = 43 * 10**7; // original buy 1ETH = 4300 Gifto = 43 * 10**7 unit
// Owner of this contract
address public owner;
// Balances Gifto for each account
mapping(address => uint256) private balances;
// Owner of account approves the transfer of an amount to another account
mapping(address => mapping (address => uint256)) private allowed;
// List of approved investors
mapping(address => bool) private approvedInvestorList;
// deposit
mapping(address => uint256) private deposit;
// icoPercent
uint256 public _icoPercent = 10;
// _icoSupply is the avalable unit. Initially, it is _totalSupply
uint256 public _icoSupply = _totalSupply * _icoPercent / 100;
// minimum buy 0.3 ETH
uint256 public _minimumBuy = 3 * 10 ** 17;
// maximum buy 25 ETH
uint256 public _maximumBuy = 25 * 10 ** 18;
// totalTokenSold
uint256 public totalTokenSold = 0;
// tradable
bool public tradable = false;
/**
* Functions with this modifier can only be executed by the owner
*/
modifier onlyOwner() {
require(msg.sender == owner);
_;
}
/**
* Functions with this modifier check on sale status
* Only allow sale if _selling is on
*/
modifier onSale() {
require(_selling);
_;
}
/**
* Functions with this modifier check the validity of address is investor
*/
modifier validInvestor() {
require(approvedInvestorList[msg.sender]);
_;
}
/**
* Functions with this modifier check the validity of msg value
* value must greater than equal minimumBuyPrice
* total deposit must less than equal maximumBuyPrice
*/
modifier validValue(){
// require value >= _minimumBuy AND total deposit of msg.sender <= maximumBuyPrice
require ( (msg.value >= _minimumBuy) &&
( (deposit[msg.sender] + msg.value) <= _maximumBuy) );
_;
}
/**
*
*/
modifier isTradable(){
require(tradable == true || msg.sender == owner);
_;
}
/// @dev Fallback function allows to buy ether.
function()
public
payable {
buyGifto();
}
/// @dev buy function allows to buy ether. for using optional data
function buyGifto()
public
payable
onSale
validValue
validInvestor {
uint256 requestedUnits = (msg.value * _originalBuyPrice) / 10**18;
require(balances[owner] >= requestedUnits);
// prepare transfer data
balances[owner] -= requestedUnits;
balances[msg.sender] += requestedUnits;
// increase total deposit amount
deposit[msg.sender] += msg.value;
// check total and auto turnOffSale
totalTokenSold += requestedUnits;
if (totalTokenSold >= _icoSupply){
_selling = false;
}
// submit transfer
Transfer(owner, msg.sender, requestedUnits);
owner.transfer(msg.value);
}
/// @dev Constructor
function Gifto()
public {
owner = msg.sender;
setBuyPrice(_originalBuyPrice);
balances[owner] = _totalSupply;
Transfer(0x0, owner, _totalSupply);
}
/// @dev Gets totalSupply
/// @return Total supply
function totalSupply()
public
constant
returns (uint256) {
return _totalSupply;
}
/// @dev Enables sale
function turnOnSale() onlyOwner
public {
_selling = true;
}
/// @dev Disables sale
function turnOffSale() onlyOwner
public {
_selling = false;
}
function turnOnTradable()
public
onlyOwner{
tradable = true;
}
/// @dev set new icoPercent
/// @param newIcoPercent new value of icoPercent
function setIcoPercent(uint256 newIcoPercent)
public
onlyOwner {
_icoPercent = newIcoPercent;
_icoSupply = _totalSupply * _icoPercent / 100;
}
/// @dev set new _maximumBuy
/// @param newMaximumBuy new value of _maximumBuy
function setMaximumBuy(uint256 newMaximumBuy)
public
onlyOwner {
_maximumBuy = newMaximumBuy;
}
/// @dev Updates buy price (owner ONLY)
/// @param newBuyPrice New buy price (in unit)
function setBuyPrice(uint256 newBuyPrice)
onlyOwner
public {
require(newBuyPrice>0);
_originalBuyPrice = newBuyPrice; // 3000 Gifto = 3000 00000 unit
// control _maximumBuy_USD = 10,000 USD, Gifto price is 0.1USD
// maximumBuy_Gifto = 100,000 Gifto = 100,000,00000 unit
// 3000 Gifto = 1ETH => maximumETH = 100,000,00000 / _originalBuyPrice
// 100,000,00000/3000 0000 ~ 33ETH => change to wei
_maximumBuy = 10**18 * 10000000000 /_originalBuyPrice;
}
/// @dev Gets account's balance
/// @param _addr Address of the account
/// @return Account balance
function balanceOf(address _addr)
public
constant
returns (uint256) {
return balances[_addr];
}
/// @dev check address is approved investor
/// @param _addr address
function isApprovedInvestor(address _addr)
public
constant
returns (bool) {
return approvedInvestorList[_addr];
}
/// @dev get ETH deposit
/// @param _addr address get deposit
/// @return amount deposit of an buyer
function getDeposit(address _addr)
public
constant
returns(uint256){
return deposit[_addr];
}
/// @dev Adds list of new investors to the investors list and approve all
/// @param newInvestorList Array of new investors addresses to be added
function addInvestorList(address[] newInvestorList)
onlyOwner
public {
for (uint256 i = 0; i < newInvestorList.length; i++){
approvedInvestorList[newInvestorList[i]] = true;
}
}
/// @dev Removes list of investors from list
/// @param investorList Array of addresses of investors to be removed
function removeInvestorList(address[] investorList)
onlyOwner
public {
for (uint256 i = 0; i < investorList.length; i++){
approvedInvestorList[investorList[i]] = false;
}
}
/// @dev Transfers the balance from msg.sender to an account
/// @param _to Recipient address
/// @param _amount Transfered amount in unit
/// @return Transfer status
function transfer(address _to, uint256 _amount)
public
isTradable
returns (bool) {
// if sender's balance has enough unit and amount >= 0,
// and the sum is not overflow,
// then do transfer
if ( (balances[msg.sender] >= _amount) &&
(_amount >= 0) &&
(balances[_to] + _amount > balances[_to]) ) {
balances[msg.sender] -= _amount;
balances[_to] += _amount;
Transfer(msg.sender, _to, _amount);
return true;
} else {
return false;
}
}
// Send _value amount of tokens from address _from to address _to
// The transferFrom method is used for a withdraw workflow, allowing contracts to send
// tokens on your behalf, for example to "deposit" to a contract address and/or to charge
// fees in sub-currencies; the command should fail unless the _from account has
// deliberately authorized the sender of the message via some mechanism; we propose
// these standardized APIs for approval:
function transferFrom(
address _from,
address _to,
uint256 _amount
)
public
isTradable
returns (bool success) {
if (balances[_from] >= _amount
&& allowed[_from][msg.sender] >= _amount
&& _amount > 0
&& balances[_to] + _amount > balances[_to]) {
balances[_from] -= _amount;
allowed[_from][msg.sender] -= _amount;
balances[_to] += _amount;
Transfer(_from, _to, _amount);
return true;
} else {
return false;
}
}
// Allow _spender to withdraw from your account, multiple times, up to the _value amount.
// If this function is called again it overwrites the current allowance with _value.
function approve(address _spender, uint256 _amount)
public
isTradable
returns (bool success) {
allowed[msg.sender][_spender] = _amount;
Approval(msg.sender, _spender, _amount);
return true;
}
// get allowance
function allowance(address _owner, address _spender)
public
constant
returns (uint256 remaining) {
return allowed[_owner][_spender];
}
/// @dev Withdraws Ether in contract (Owner only)
/// @return Status of withdrawal
function withdraw() onlyOwner
public
returns (bool) {
return owner.send(this.balance);
}
} | transfer | function transfer(address _to, uint256 _amount)
public
isTradable
returns (bool) {
// if sender's balance has enough unit and amount >= 0,
// and the sum is not overflow,
// then do transfer
if ( (balances[msg.sender] >= _amount) &&
(_amount >= 0) &&
(balances[_to] + _amount > balances[_to]) ) {
balances[msg.sender] -= _amount;
balances[_to] += _amount;
Transfer(msg.sender, _to, _amount);
return true;
} else {
return false;
}
}
| /// @dev Transfers the balance from msg.sender to an account
/// @param _to Recipient address
/// @param _amount Transfered amount in unit
/// @return Transfer status | NatSpecSingleLine | v0.4.18+commit.9cf6e910 | bzzr://891e8485538f16f2fa5b9af11f8c795bc62d51fb6455063a6ee3652fa7680f20 | {
"func_code_index": [
7239,
7867
]
} | 3,528 |
|||
MultiSigWallet | MultiSigWallet.sol | 0x615ed6779507f223d04722d43ccc0cd871964e2a | Solidity | Gifto | contract Gifto is ERC20Interface {
uint256 public constant decimals = 5;
string public constant symbol = "GTO";
string public constant name = "Gifto";
bool public _selling = true;//initial selling
uint256 public _totalSupply = 10 ** 14; // total supply is 10^14 unit, equivalent to 10^9 Gifto
uint256 public _originalBuyPrice = 43 * 10**7; // original buy 1ETH = 4300 Gifto = 43 * 10**7 unit
// Owner of this contract
address public owner;
// Balances Gifto for each account
mapping(address => uint256) private balances;
// Owner of account approves the transfer of an amount to another account
mapping(address => mapping (address => uint256)) private allowed;
// List of approved investors
mapping(address => bool) private approvedInvestorList;
// deposit
mapping(address => uint256) private deposit;
// icoPercent
uint256 public _icoPercent = 10;
// _icoSupply is the avalable unit. Initially, it is _totalSupply
uint256 public _icoSupply = _totalSupply * _icoPercent / 100;
// minimum buy 0.3 ETH
uint256 public _minimumBuy = 3 * 10 ** 17;
// maximum buy 25 ETH
uint256 public _maximumBuy = 25 * 10 ** 18;
// totalTokenSold
uint256 public totalTokenSold = 0;
// tradable
bool public tradable = false;
/**
* Functions with this modifier can only be executed by the owner
*/
modifier onlyOwner() {
require(msg.sender == owner);
_;
}
/**
* Functions with this modifier check on sale status
* Only allow sale if _selling is on
*/
modifier onSale() {
require(_selling);
_;
}
/**
* Functions with this modifier check the validity of address is investor
*/
modifier validInvestor() {
require(approvedInvestorList[msg.sender]);
_;
}
/**
* Functions with this modifier check the validity of msg value
* value must greater than equal minimumBuyPrice
* total deposit must less than equal maximumBuyPrice
*/
modifier validValue(){
// require value >= _minimumBuy AND total deposit of msg.sender <= maximumBuyPrice
require ( (msg.value >= _minimumBuy) &&
( (deposit[msg.sender] + msg.value) <= _maximumBuy) );
_;
}
/**
*
*/
modifier isTradable(){
require(tradable == true || msg.sender == owner);
_;
}
/// @dev Fallback function allows to buy ether.
function()
public
payable {
buyGifto();
}
/// @dev buy function allows to buy ether. for using optional data
function buyGifto()
public
payable
onSale
validValue
validInvestor {
uint256 requestedUnits = (msg.value * _originalBuyPrice) / 10**18;
require(balances[owner] >= requestedUnits);
// prepare transfer data
balances[owner] -= requestedUnits;
balances[msg.sender] += requestedUnits;
// increase total deposit amount
deposit[msg.sender] += msg.value;
// check total and auto turnOffSale
totalTokenSold += requestedUnits;
if (totalTokenSold >= _icoSupply){
_selling = false;
}
// submit transfer
Transfer(owner, msg.sender, requestedUnits);
owner.transfer(msg.value);
}
/// @dev Constructor
function Gifto()
public {
owner = msg.sender;
setBuyPrice(_originalBuyPrice);
balances[owner] = _totalSupply;
Transfer(0x0, owner, _totalSupply);
}
/// @dev Gets totalSupply
/// @return Total supply
function totalSupply()
public
constant
returns (uint256) {
return _totalSupply;
}
/// @dev Enables sale
function turnOnSale() onlyOwner
public {
_selling = true;
}
/// @dev Disables sale
function turnOffSale() onlyOwner
public {
_selling = false;
}
function turnOnTradable()
public
onlyOwner{
tradable = true;
}
/// @dev set new icoPercent
/// @param newIcoPercent new value of icoPercent
function setIcoPercent(uint256 newIcoPercent)
public
onlyOwner {
_icoPercent = newIcoPercent;
_icoSupply = _totalSupply * _icoPercent / 100;
}
/// @dev set new _maximumBuy
/// @param newMaximumBuy new value of _maximumBuy
function setMaximumBuy(uint256 newMaximumBuy)
public
onlyOwner {
_maximumBuy = newMaximumBuy;
}
/// @dev Updates buy price (owner ONLY)
/// @param newBuyPrice New buy price (in unit)
function setBuyPrice(uint256 newBuyPrice)
onlyOwner
public {
require(newBuyPrice>0);
_originalBuyPrice = newBuyPrice; // 3000 Gifto = 3000 00000 unit
// control _maximumBuy_USD = 10,000 USD, Gifto price is 0.1USD
// maximumBuy_Gifto = 100,000 Gifto = 100,000,00000 unit
// 3000 Gifto = 1ETH => maximumETH = 100,000,00000 / _originalBuyPrice
// 100,000,00000/3000 0000 ~ 33ETH => change to wei
_maximumBuy = 10**18 * 10000000000 /_originalBuyPrice;
}
/// @dev Gets account's balance
/// @param _addr Address of the account
/// @return Account balance
function balanceOf(address _addr)
public
constant
returns (uint256) {
return balances[_addr];
}
/// @dev check address is approved investor
/// @param _addr address
function isApprovedInvestor(address _addr)
public
constant
returns (bool) {
return approvedInvestorList[_addr];
}
/// @dev get ETH deposit
/// @param _addr address get deposit
/// @return amount deposit of an buyer
function getDeposit(address _addr)
public
constant
returns(uint256){
return deposit[_addr];
}
/// @dev Adds list of new investors to the investors list and approve all
/// @param newInvestorList Array of new investors addresses to be added
function addInvestorList(address[] newInvestorList)
onlyOwner
public {
for (uint256 i = 0; i < newInvestorList.length; i++){
approvedInvestorList[newInvestorList[i]] = true;
}
}
/// @dev Removes list of investors from list
/// @param investorList Array of addresses of investors to be removed
function removeInvestorList(address[] investorList)
onlyOwner
public {
for (uint256 i = 0; i < investorList.length; i++){
approvedInvestorList[investorList[i]] = false;
}
}
/// @dev Transfers the balance from msg.sender to an account
/// @param _to Recipient address
/// @param _amount Transfered amount in unit
/// @return Transfer status
function transfer(address _to, uint256 _amount)
public
isTradable
returns (bool) {
// if sender's balance has enough unit and amount >= 0,
// and the sum is not overflow,
// then do transfer
if ( (balances[msg.sender] >= _amount) &&
(_amount >= 0) &&
(balances[_to] + _amount > balances[_to]) ) {
balances[msg.sender] -= _amount;
balances[_to] += _amount;
Transfer(msg.sender, _to, _amount);
return true;
} else {
return false;
}
}
// Send _value amount of tokens from address _from to address _to
// The transferFrom method is used for a withdraw workflow, allowing contracts to send
// tokens on your behalf, for example to "deposit" to a contract address and/or to charge
// fees in sub-currencies; the command should fail unless the _from account has
// deliberately authorized the sender of the message via some mechanism; we propose
// these standardized APIs for approval:
function transferFrom(
address _from,
address _to,
uint256 _amount
)
public
isTradable
returns (bool success) {
if (balances[_from] >= _amount
&& allowed[_from][msg.sender] >= _amount
&& _amount > 0
&& balances[_to] + _amount > balances[_to]) {
balances[_from] -= _amount;
allowed[_from][msg.sender] -= _amount;
balances[_to] += _amount;
Transfer(_from, _to, _amount);
return true;
} else {
return false;
}
}
// Allow _spender to withdraw from your account, multiple times, up to the _value amount.
// If this function is called again it overwrites the current allowance with _value.
function approve(address _spender, uint256 _amount)
public
isTradable
returns (bool success) {
allowed[msg.sender][_spender] = _amount;
Approval(msg.sender, _spender, _amount);
return true;
}
// get allowance
function allowance(address _owner, address _spender)
public
constant
returns (uint256 remaining) {
return allowed[_owner][_spender];
}
/// @dev Withdraws Ether in contract (Owner only)
/// @return Status of withdrawal
function withdraw() onlyOwner
public
returns (bool) {
return owner.send(this.balance);
}
} | transferFrom | function transferFrom(
address _from,
address _to,
uint256 _amount
)
public
isTradable
returns (bool success) {
if (balances[_from] >= _amount
&& allowed[_from][msg.sender] >= _amount
&& _amount > 0
&& balances[_to] + _amount > balances[_to]) {
balances[_from] -= _amount;
allowed[_from][msg.sender] -= _amount;
balances[_to] += _amount;
Transfer(_from, _to, _amount);
return true;
} else {
return false;
}
}
| // Send _value amount of tokens from address _from to address _to
// The transferFrom method is used for a withdraw workflow, allowing contracts to send
// tokens on your behalf, for example to "deposit" to a contract address and/or to charge
// fees in sub-currencies; the command should fail unless the _from account has
// deliberately authorized the sender of the message via some mechanism; we propose
// these standardized APIs for approval: | LineComment | v0.4.18+commit.9cf6e910 | bzzr://891e8485538f16f2fa5b9af11f8c795bc62d51fb6455063a6ee3652fa7680f20 | {
"func_code_index": [
8353,
8962
]
} | 3,529 |
|||
MultiSigWallet | MultiSigWallet.sol | 0x615ed6779507f223d04722d43ccc0cd871964e2a | Solidity | Gifto | contract Gifto is ERC20Interface {
uint256 public constant decimals = 5;
string public constant symbol = "GTO";
string public constant name = "Gifto";
bool public _selling = true;//initial selling
uint256 public _totalSupply = 10 ** 14; // total supply is 10^14 unit, equivalent to 10^9 Gifto
uint256 public _originalBuyPrice = 43 * 10**7; // original buy 1ETH = 4300 Gifto = 43 * 10**7 unit
// Owner of this contract
address public owner;
// Balances Gifto for each account
mapping(address => uint256) private balances;
// Owner of account approves the transfer of an amount to another account
mapping(address => mapping (address => uint256)) private allowed;
// List of approved investors
mapping(address => bool) private approvedInvestorList;
// deposit
mapping(address => uint256) private deposit;
// icoPercent
uint256 public _icoPercent = 10;
// _icoSupply is the avalable unit. Initially, it is _totalSupply
uint256 public _icoSupply = _totalSupply * _icoPercent / 100;
// minimum buy 0.3 ETH
uint256 public _minimumBuy = 3 * 10 ** 17;
// maximum buy 25 ETH
uint256 public _maximumBuy = 25 * 10 ** 18;
// totalTokenSold
uint256 public totalTokenSold = 0;
// tradable
bool public tradable = false;
/**
* Functions with this modifier can only be executed by the owner
*/
modifier onlyOwner() {
require(msg.sender == owner);
_;
}
/**
* Functions with this modifier check on sale status
* Only allow sale if _selling is on
*/
modifier onSale() {
require(_selling);
_;
}
/**
* Functions with this modifier check the validity of address is investor
*/
modifier validInvestor() {
require(approvedInvestorList[msg.sender]);
_;
}
/**
* Functions with this modifier check the validity of msg value
* value must greater than equal minimumBuyPrice
* total deposit must less than equal maximumBuyPrice
*/
modifier validValue(){
// require value >= _minimumBuy AND total deposit of msg.sender <= maximumBuyPrice
require ( (msg.value >= _minimumBuy) &&
( (deposit[msg.sender] + msg.value) <= _maximumBuy) );
_;
}
/**
*
*/
modifier isTradable(){
require(tradable == true || msg.sender == owner);
_;
}
/// @dev Fallback function allows to buy ether.
function()
public
payable {
buyGifto();
}
/// @dev buy function allows to buy ether. for using optional data
function buyGifto()
public
payable
onSale
validValue
validInvestor {
uint256 requestedUnits = (msg.value * _originalBuyPrice) / 10**18;
require(balances[owner] >= requestedUnits);
// prepare transfer data
balances[owner] -= requestedUnits;
balances[msg.sender] += requestedUnits;
// increase total deposit amount
deposit[msg.sender] += msg.value;
// check total and auto turnOffSale
totalTokenSold += requestedUnits;
if (totalTokenSold >= _icoSupply){
_selling = false;
}
// submit transfer
Transfer(owner, msg.sender, requestedUnits);
owner.transfer(msg.value);
}
/// @dev Constructor
function Gifto()
public {
owner = msg.sender;
setBuyPrice(_originalBuyPrice);
balances[owner] = _totalSupply;
Transfer(0x0, owner, _totalSupply);
}
/// @dev Gets totalSupply
/// @return Total supply
function totalSupply()
public
constant
returns (uint256) {
return _totalSupply;
}
/// @dev Enables sale
function turnOnSale() onlyOwner
public {
_selling = true;
}
/// @dev Disables sale
function turnOffSale() onlyOwner
public {
_selling = false;
}
function turnOnTradable()
public
onlyOwner{
tradable = true;
}
/// @dev set new icoPercent
/// @param newIcoPercent new value of icoPercent
function setIcoPercent(uint256 newIcoPercent)
public
onlyOwner {
_icoPercent = newIcoPercent;
_icoSupply = _totalSupply * _icoPercent / 100;
}
/// @dev set new _maximumBuy
/// @param newMaximumBuy new value of _maximumBuy
function setMaximumBuy(uint256 newMaximumBuy)
public
onlyOwner {
_maximumBuy = newMaximumBuy;
}
/// @dev Updates buy price (owner ONLY)
/// @param newBuyPrice New buy price (in unit)
function setBuyPrice(uint256 newBuyPrice)
onlyOwner
public {
require(newBuyPrice>0);
_originalBuyPrice = newBuyPrice; // 3000 Gifto = 3000 00000 unit
// control _maximumBuy_USD = 10,000 USD, Gifto price is 0.1USD
// maximumBuy_Gifto = 100,000 Gifto = 100,000,00000 unit
// 3000 Gifto = 1ETH => maximumETH = 100,000,00000 / _originalBuyPrice
// 100,000,00000/3000 0000 ~ 33ETH => change to wei
_maximumBuy = 10**18 * 10000000000 /_originalBuyPrice;
}
/// @dev Gets account's balance
/// @param _addr Address of the account
/// @return Account balance
function balanceOf(address _addr)
public
constant
returns (uint256) {
return balances[_addr];
}
/// @dev check address is approved investor
/// @param _addr address
function isApprovedInvestor(address _addr)
public
constant
returns (bool) {
return approvedInvestorList[_addr];
}
/// @dev get ETH deposit
/// @param _addr address get deposit
/// @return amount deposit of an buyer
function getDeposit(address _addr)
public
constant
returns(uint256){
return deposit[_addr];
}
/// @dev Adds list of new investors to the investors list and approve all
/// @param newInvestorList Array of new investors addresses to be added
function addInvestorList(address[] newInvestorList)
onlyOwner
public {
for (uint256 i = 0; i < newInvestorList.length; i++){
approvedInvestorList[newInvestorList[i]] = true;
}
}
/// @dev Removes list of investors from list
/// @param investorList Array of addresses of investors to be removed
function removeInvestorList(address[] investorList)
onlyOwner
public {
for (uint256 i = 0; i < investorList.length; i++){
approvedInvestorList[investorList[i]] = false;
}
}
/// @dev Transfers the balance from msg.sender to an account
/// @param _to Recipient address
/// @param _amount Transfered amount in unit
/// @return Transfer status
function transfer(address _to, uint256 _amount)
public
isTradable
returns (bool) {
// if sender's balance has enough unit and amount >= 0,
// and the sum is not overflow,
// then do transfer
if ( (balances[msg.sender] >= _amount) &&
(_amount >= 0) &&
(balances[_to] + _amount > balances[_to]) ) {
balances[msg.sender] -= _amount;
balances[_to] += _amount;
Transfer(msg.sender, _to, _amount);
return true;
} else {
return false;
}
}
// Send _value amount of tokens from address _from to address _to
// The transferFrom method is used for a withdraw workflow, allowing contracts to send
// tokens on your behalf, for example to "deposit" to a contract address and/or to charge
// fees in sub-currencies; the command should fail unless the _from account has
// deliberately authorized the sender of the message via some mechanism; we propose
// these standardized APIs for approval:
function transferFrom(
address _from,
address _to,
uint256 _amount
)
public
isTradable
returns (bool success) {
if (balances[_from] >= _amount
&& allowed[_from][msg.sender] >= _amount
&& _amount > 0
&& balances[_to] + _amount > balances[_to]) {
balances[_from] -= _amount;
allowed[_from][msg.sender] -= _amount;
balances[_to] += _amount;
Transfer(_from, _to, _amount);
return true;
} else {
return false;
}
}
// Allow _spender to withdraw from your account, multiple times, up to the _value amount.
// If this function is called again it overwrites the current allowance with _value.
function approve(address _spender, uint256 _amount)
public
isTradable
returns (bool success) {
allowed[msg.sender][_spender] = _amount;
Approval(msg.sender, _spender, _amount);
return true;
}
// get allowance
function allowance(address _owner, address _spender)
public
constant
returns (uint256 remaining) {
return allowed[_owner][_spender];
}
/// @dev Withdraws Ether in contract (Owner only)
/// @return Status of withdrawal
function withdraw() onlyOwner
public
returns (bool) {
return owner.send(this.balance);
}
} | approve | function approve(address _spender, uint256 _amount)
public
isTradable
returns (bool success) {
allowed[msg.sender][_spender] = _amount;
Approval(msg.sender, _spender, _amount);
return true;
}
| // Allow _spender to withdraw from your account, multiple times, up to the _value amount.
// If this function is called again it overwrites the current allowance with _value. | LineComment | v0.4.18+commit.9cf6e910 | bzzr://891e8485538f16f2fa5b9af11f8c795bc62d51fb6455063a6ee3652fa7680f20 | {
"func_code_index": [
9154,
9410
]
} | 3,530 |
|||
MultiSigWallet | MultiSigWallet.sol | 0x615ed6779507f223d04722d43ccc0cd871964e2a | Solidity | Gifto | contract Gifto is ERC20Interface {
uint256 public constant decimals = 5;
string public constant symbol = "GTO";
string public constant name = "Gifto";
bool public _selling = true;//initial selling
uint256 public _totalSupply = 10 ** 14; // total supply is 10^14 unit, equivalent to 10^9 Gifto
uint256 public _originalBuyPrice = 43 * 10**7; // original buy 1ETH = 4300 Gifto = 43 * 10**7 unit
// Owner of this contract
address public owner;
// Balances Gifto for each account
mapping(address => uint256) private balances;
// Owner of account approves the transfer of an amount to another account
mapping(address => mapping (address => uint256)) private allowed;
// List of approved investors
mapping(address => bool) private approvedInvestorList;
// deposit
mapping(address => uint256) private deposit;
// icoPercent
uint256 public _icoPercent = 10;
// _icoSupply is the avalable unit. Initially, it is _totalSupply
uint256 public _icoSupply = _totalSupply * _icoPercent / 100;
// minimum buy 0.3 ETH
uint256 public _minimumBuy = 3 * 10 ** 17;
// maximum buy 25 ETH
uint256 public _maximumBuy = 25 * 10 ** 18;
// totalTokenSold
uint256 public totalTokenSold = 0;
// tradable
bool public tradable = false;
/**
* Functions with this modifier can only be executed by the owner
*/
modifier onlyOwner() {
require(msg.sender == owner);
_;
}
/**
* Functions with this modifier check on sale status
* Only allow sale if _selling is on
*/
modifier onSale() {
require(_selling);
_;
}
/**
* Functions with this modifier check the validity of address is investor
*/
modifier validInvestor() {
require(approvedInvestorList[msg.sender]);
_;
}
/**
* Functions with this modifier check the validity of msg value
* value must greater than equal minimumBuyPrice
* total deposit must less than equal maximumBuyPrice
*/
modifier validValue(){
// require value >= _minimumBuy AND total deposit of msg.sender <= maximumBuyPrice
require ( (msg.value >= _minimumBuy) &&
( (deposit[msg.sender] + msg.value) <= _maximumBuy) );
_;
}
/**
*
*/
modifier isTradable(){
require(tradable == true || msg.sender == owner);
_;
}
/// @dev Fallback function allows to buy ether.
function()
public
payable {
buyGifto();
}
/// @dev buy function allows to buy ether. for using optional data
function buyGifto()
public
payable
onSale
validValue
validInvestor {
uint256 requestedUnits = (msg.value * _originalBuyPrice) / 10**18;
require(balances[owner] >= requestedUnits);
// prepare transfer data
balances[owner] -= requestedUnits;
balances[msg.sender] += requestedUnits;
// increase total deposit amount
deposit[msg.sender] += msg.value;
// check total and auto turnOffSale
totalTokenSold += requestedUnits;
if (totalTokenSold >= _icoSupply){
_selling = false;
}
// submit transfer
Transfer(owner, msg.sender, requestedUnits);
owner.transfer(msg.value);
}
/// @dev Constructor
function Gifto()
public {
owner = msg.sender;
setBuyPrice(_originalBuyPrice);
balances[owner] = _totalSupply;
Transfer(0x0, owner, _totalSupply);
}
/// @dev Gets totalSupply
/// @return Total supply
function totalSupply()
public
constant
returns (uint256) {
return _totalSupply;
}
/// @dev Enables sale
function turnOnSale() onlyOwner
public {
_selling = true;
}
/// @dev Disables sale
function turnOffSale() onlyOwner
public {
_selling = false;
}
function turnOnTradable()
public
onlyOwner{
tradable = true;
}
/// @dev set new icoPercent
/// @param newIcoPercent new value of icoPercent
function setIcoPercent(uint256 newIcoPercent)
public
onlyOwner {
_icoPercent = newIcoPercent;
_icoSupply = _totalSupply * _icoPercent / 100;
}
/// @dev set new _maximumBuy
/// @param newMaximumBuy new value of _maximumBuy
function setMaximumBuy(uint256 newMaximumBuy)
public
onlyOwner {
_maximumBuy = newMaximumBuy;
}
/// @dev Updates buy price (owner ONLY)
/// @param newBuyPrice New buy price (in unit)
function setBuyPrice(uint256 newBuyPrice)
onlyOwner
public {
require(newBuyPrice>0);
_originalBuyPrice = newBuyPrice; // 3000 Gifto = 3000 00000 unit
// control _maximumBuy_USD = 10,000 USD, Gifto price is 0.1USD
// maximumBuy_Gifto = 100,000 Gifto = 100,000,00000 unit
// 3000 Gifto = 1ETH => maximumETH = 100,000,00000 / _originalBuyPrice
// 100,000,00000/3000 0000 ~ 33ETH => change to wei
_maximumBuy = 10**18 * 10000000000 /_originalBuyPrice;
}
/// @dev Gets account's balance
/// @param _addr Address of the account
/// @return Account balance
function balanceOf(address _addr)
public
constant
returns (uint256) {
return balances[_addr];
}
/// @dev check address is approved investor
/// @param _addr address
function isApprovedInvestor(address _addr)
public
constant
returns (bool) {
return approvedInvestorList[_addr];
}
/// @dev get ETH deposit
/// @param _addr address get deposit
/// @return amount deposit of an buyer
function getDeposit(address _addr)
public
constant
returns(uint256){
return deposit[_addr];
}
/// @dev Adds list of new investors to the investors list and approve all
/// @param newInvestorList Array of new investors addresses to be added
function addInvestorList(address[] newInvestorList)
onlyOwner
public {
for (uint256 i = 0; i < newInvestorList.length; i++){
approvedInvestorList[newInvestorList[i]] = true;
}
}
/// @dev Removes list of investors from list
/// @param investorList Array of addresses of investors to be removed
function removeInvestorList(address[] investorList)
onlyOwner
public {
for (uint256 i = 0; i < investorList.length; i++){
approvedInvestorList[investorList[i]] = false;
}
}
/// @dev Transfers the balance from msg.sender to an account
/// @param _to Recipient address
/// @param _amount Transfered amount in unit
/// @return Transfer status
function transfer(address _to, uint256 _amount)
public
isTradable
returns (bool) {
// if sender's balance has enough unit and amount >= 0,
// and the sum is not overflow,
// then do transfer
if ( (balances[msg.sender] >= _amount) &&
(_amount >= 0) &&
(balances[_to] + _amount > balances[_to]) ) {
balances[msg.sender] -= _amount;
balances[_to] += _amount;
Transfer(msg.sender, _to, _amount);
return true;
} else {
return false;
}
}
// Send _value amount of tokens from address _from to address _to
// The transferFrom method is used for a withdraw workflow, allowing contracts to send
// tokens on your behalf, for example to "deposit" to a contract address and/or to charge
// fees in sub-currencies; the command should fail unless the _from account has
// deliberately authorized the sender of the message via some mechanism; we propose
// these standardized APIs for approval:
function transferFrom(
address _from,
address _to,
uint256 _amount
)
public
isTradable
returns (bool success) {
if (balances[_from] >= _amount
&& allowed[_from][msg.sender] >= _amount
&& _amount > 0
&& balances[_to] + _amount > balances[_to]) {
balances[_from] -= _amount;
allowed[_from][msg.sender] -= _amount;
balances[_to] += _amount;
Transfer(_from, _to, _amount);
return true;
} else {
return false;
}
}
// Allow _spender to withdraw from your account, multiple times, up to the _value amount.
// If this function is called again it overwrites the current allowance with _value.
function approve(address _spender, uint256 _amount)
public
isTradable
returns (bool success) {
allowed[msg.sender][_spender] = _amount;
Approval(msg.sender, _spender, _amount);
return true;
}
// get allowance
function allowance(address _owner, address _spender)
public
constant
returns (uint256 remaining) {
return allowed[_owner][_spender];
}
/// @dev Withdraws Ether in contract (Owner only)
/// @return Status of withdrawal
function withdraw() onlyOwner
public
returns (bool) {
return owner.send(this.balance);
}
} | allowance | function allowance(address _owner, address _spender)
public
constant
returns (uint256 remaining) {
return allowed[_owner][_spender];
}
| // get allowance | LineComment | v0.4.18+commit.9cf6e910 | bzzr://891e8485538f16f2fa5b9af11f8c795bc62d51fb6455063a6ee3652fa7680f20 | {
"func_code_index": [
9439,
9621
]
} | 3,531 |
|||
MultiSigWallet | MultiSigWallet.sol | 0x615ed6779507f223d04722d43ccc0cd871964e2a | Solidity | Gifto | contract Gifto is ERC20Interface {
uint256 public constant decimals = 5;
string public constant symbol = "GTO";
string public constant name = "Gifto";
bool public _selling = true;//initial selling
uint256 public _totalSupply = 10 ** 14; // total supply is 10^14 unit, equivalent to 10^9 Gifto
uint256 public _originalBuyPrice = 43 * 10**7; // original buy 1ETH = 4300 Gifto = 43 * 10**7 unit
// Owner of this contract
address public owner;
// Balances Gifto for each account
mapping(address => uint256) private balances;
// Owner of account approves the transfer of an amount to another account
mapping(address => mapping (address => uint256)) private allowed;
// List of approved investors
mapping(address => bool) private approvedInvestorList;
// deposit
mapping(address => uint256) private deposit;
// icoPercent
uint256 public _icoPercent = 10;
// _icoSupply is the avalable unit. Initially, it is _totalSupply
uint256 public _icoSupply = _totalSupply * _icoPercent / 100;
// minimum buy 0.3 ETH
uint256 public _minimumBuy = 3 * 10 ** 17;
// maximum buy 25 ETH
uint256 public _maximumBuy = 25 * 10 ** 18;
// totalTokenSold
uint256 public totalTokenSold = 0;
// tradable
bool public tradable = false;
/**
* Functions with this modifier can only be executed by the owner
*/
modifier onlyOwner() {
require(msg.sender == owner);
_;
}
/**
* Functions with this modifier check on sale status
* Only allow sale if _selling is on
*/
modifier onSale() {
require(_selling);
_;
}
/**
* Functions with this modifier check the validity of address is investor
*/
modifier validInvestor() {
require(approvedInvestorList[msg.sender]);
_;
}
/**
* Functions with this modifier check the validity of msg value
* value must greater than equal minimumBuyPrice
* total deposit must less than equal maximumBuyPrice
*/
modifier validValue(){
// require value >= _minimumBuy AND total deposit of msg.sender <= maximumBuyPrice
require ( (msg.value >= _minimumBuy) &&
( (deposit[msg.sender] + msg.value) <= _maximumBuy) );
_;
}
/**
*
*/
modifier isTradable(){
require(tradable == true || msg.sender == owner);
_;
}
/// @dev Fallback function allows to buy ether.
function()
public
payable {
buyGifto();
}
/// @dev buy function allows to buy ether. for using optional data
function buyGifto()
public
payable
onSale
validValue
validInvestor {
uint256 requestedUnits = (msg.value * _originalBuyPrice) / 10**18;
require(balances[owner] >= requestedUnits);
// prepare transfer data
balances[owner] -= requestedUnits;
balances[msg.sender] += requestedUnits;
// increase total deposit amount
deposit[msg.sender] += msg.value;
// check total and auto turnOffSale
totalTokenSold += requestedUnits;
if (totalTokenSold >= _icoSupply){
_selling = false;
}
// submit transfer
Transfer(owner, msg.sender, requestedUnits);
owner.transfer(msg.value);
}
/// @dev Constructor
function Gifto()
public {
owner = msg.sender;
setBuyPrice(_originalBuyPrice);
balances[owner] = _totalSupply;
Transfer(0x0, owner, _totalSupply);
}
/// @dev Gets totalSupply
/// @return Total supply
function totalSupply()
public
constant
returns (uint256) {
return _totalSupply;
}
/// @dev Enables sale
function turnOnSale() onlyOwner
public {
_selling = true;
}
/// @dev Disables sale
function turnOffSale() onlyOwner
public {
_selling = false;
}
function turnOnTradable()
public
onlyOwner{
tradable = true;
}
/// @dev set new icoPercent
/// @param newIcoPercent new value of icoPercent
function setIcoPercent(uint256 newIcoPercent)
public
onlyOwner {
_icoPercent = newIcoPercent;
_icoSupply = _totalSupply * _icoPercent / 100;
}
/// @dev set new _maximumBuy
/// @param newMaximumBuy new value of _maximumBuy
function setMaximumBuy(uint256 newMaximumBuy)
public
onlyOwner {
_maximumBuy = newMaximumBuy;
}
/// @dev Updates buy price (owner ONLY)
/// @param newBuyPrice New buy price (in unit)
function setBuyPrice(uint256 newBuyPrice)
onlyOwner
public {
require(newBuyPrice>0);
_originalBuyPrice = newBuyPrice; // 3000 Gifto = 3000 00000 unit
// control _maximumBuy_USD = 10,000 USD, Gifto price is 0.1USD
// maximumBuy_Gifto = 100,000 Gifto = 100,000,00000 unit
// 3000 Gifto = 1ETH => maximumETH = 100,000,00000 / _originalBuyPrice
// 100,000,00000/3000 0000 ~ 33ETH => change to wei
_maximumBuy = 10**18 * 10000000000 /_originalBuyPrice;
}
/// @dev Gets account's balance
/// @param _addr Address of the account
/// @return Account balance
function balanceOf(address _addr)
public
constant
returns (uint256) {
return balances[_addr];
}
/// @dev check address is approved investor
/// @param _addr address
function isApprovedInvestor(address _addr)
public
constant
returns (bool) {
return approvedInvestorList[_addr];
}
/// @dev get ETH deposit
/// @param _addr address get deposit
/// @return amount deposit of an buyer
function getDeposit(address _addr)
public
constant
returns(uint256){
return deposit[_addr];
}
/// @dev Adds list of new investors to the investors list and approve all
/// @param newInvestorList Array of new investors addresses to be added
function addInvestorList(address[] newInvestorList)
onlyOwner
public {
for (uint256 i = 0; i < newInvestorList.length; i++){
approvedInvestorList[newInvestorList[i]] = true;
}
}
/// @dev Removes list of investors from list
/// @param investorList Array of addresses of investors to be removed
function removeInvestorList(address[] investorList)
onlyOwner
public {
for (uint256 i = 0; i < investorList.length; i++){
approvedInvestorList[investorList[i]] = false;
}
}
/// @dev Transfers the balance from msg.sender to an account
/// @param _to Recipient address
/// @param _amount Transfered amount in unit
/// @return Transfer status
function transfer(address _to, uint256 _amount)
public
isTradable
returns (bool) {
// if sender's balance has enough unit and amount >= 0,
// and the sum is not overflow,
// then do transfer
if ( (balances[msg.sender] >= _amount) &&
(_amount >= 0) &&
(balances[_to] + _amount > balances[_to]) ) {
balances[msg.sender] -= _amount;
balances[_to] += _amount;
Transfer(msg.sender, _to, _amount);
return true;
} else {
return false;
}
}
// Send _value amount of tokens from address _from to address _to
// The transferFrom method is used for a withdraw workflow, allowing contracts to send
// tokens on your behalf, for example to "deposit" to a contract address and/or to charge
// fees in sub-currencies; the command should fail unless the _from account has
// deliberately authorized the sender of the message via some mechanism; we propose
// these standardized APIs for approval:
function transferFrom(
address _from,
address _to,
uint256 _amount
)
public
isTradable
returns (bool success) {
if (balances[_from] >= _amount
&& allowed[_from][msg.sender] >= _amount
&& _amount > 0
&& balances[_to] + _amount > balances[_to]) {
balances[_from] -= _amount;
allowed[_from][msg.sender] -= _amount;
balances[_to] += _amount;
Transfer(_from, _to, _amount);
return true;
} else {
return false;
}
}
// Allow _spender to withdraw from your account, multiple times, up to the _value amount.
// If this function is called again it overwrites the current allowance with _value.
function approve(address _spender, uint256 _amount)
public
isTradable
returns (bool success) {
allowed[msg.sender][_spender] = _amount;
Approval(msg.sender, _spender, _amount);
return true;
}
// get allowance
function allowance(address _owner, address _spender)
public
constant
returns (uint256 remaining) {
return allowed[_owner][_spender];
}
/// @dev Withdraws Ether in contract (Owner only)
/// @return Status of withdrawal
function withdraw() onlyOwner
public
returns (bool) {
return owner.send(this.balance);
}
} | withdraw | function withdraw() onlyOwner
public
returns (bool) {
return owner.send(this.balance);
}
| /// @dev Withdraws Ether in contract (Owner only)
/// @return Status of withdrawal | NatSpecSingleLine | v0.4.18+commit.9cf6e910 | bzzr://891e8485538f16f2fa5b9af11f8c795bc62d51fb6455063a6ee3652fa7680f20 | {
"func_code_index": [
9721,
9848
]
} | 3,532 |
|||
MultiSigWallet | MultiSigWallet.sol | 0x615ed6779507f223d04722d43ccc0cd871964e2a | Solidity | MultiSigWallet | contract MultiSigWallet {
uint constant public MAX_OWNER_COUNT = 50;
event Confirmation(address indexed sender, uint indexed transactionId);
event Revocation(address indexed sender, uint indexed transactionId);
event Submission(uint indexed transactionId);
event Execution(uint indexed transactionId);
event ExecutionFailure(uint indexed transactionId);
event Deposit(address indexed sender, uint value);
event OwnerAddition(address indexed owner);
event OwnerRemoval(address indexed owner);
event RequirementChange(uint required);
event CoinCreation(address coin);
mapping (uint => Transaction) public transactions;
mapping (uint => mapping (address => bool)) public confirmations;
mapping (address => bool) public isOwner;
address[] public owners;
uint public required;
uint public transactionCount;
bool flag = true;
struct Transaction {
address destination;
uint value;
bytes data;
bool executed;
}
modifier onlyWallet() {
if (msg.sender != address(this))
revert();
_;
}
modifier ownerDoesNotExist(address owner) {
if (isOwner[owner])
revert();
_;
}
modifier ownerExists(address owner) {
if (!isOwner[owner])
revert();
_;
}
modifier transactionExists(uint transactionId) {
if (transactions[transactionId].destination == 0)
revert();
_;
}
modifier confirmed(uint transactionId, address owner) {
if (!confirmations[transactionId][owner])
revert();
_;
}
modifier notConfirmed(uint transactionId, address owner) {
if (confirmations[transactionId][owner])
revert();
_;
}
modifier notExecuted(uint transactionId) {
if (transactions[transactionId].executed)
revert();
_;
}
modifier notNull(address _address) {
if (_address == 0)
revert();
_;
}
modifier validRequirement(uint ownerCount, uint _required) {
if ( ownerCount > MAX_OWNER_COUNT
|| _required > ownerCount
|| _required == 0
|| ownerCount == 0)
revert();
_;
}
/// @dev Fallback function allows to deposit ether.
function()
payable
{
if (msg.value > 0)
Deposit(msg.sender, msg.value);
}
/*
* Public functions
*/
/// @dev Contract constructor sets initial owners and required number of confirmations.
/// @param _owners List of initial owners.
/// @param _required Number of required confirmations.
function MultiSigWallet(address[] _owners, uint _required)
public
validRequirement(_owners.length, _required)
{
for (uint i=0; i<_owners.length; i++) {
if (isOwner[_owners[i]] || _owners[i] == 0)
revert();
isOwner[_owners[i]] = true;
}
owners = _owners;
required = _required;
}
/// @dev Allows to add a new owner. Transaction has to be sent by wallet.
/// @param owner Address of new owner.
function addOwner(address owner)
public
onlyWallet
ownerDoesNotExist(owner)
notNull(owner)
validRequirement(owners.length + 1, required)
{
isOwner[owner] = true;
owners.push(owner);
OwnerAddition(owner);
}
/// @dev Allows to remove an owner. Transaction has to be sent by wallet.
/// @param owner Address of owner.
function removeOwner(address owner)
public
onlyWallet
ownerExists(owner)
{
isOwner[owner] = false;
for (uint i=0; i<owners.length - 1; i++)
if (owners[i] == owner) {
owners[i] = owners[owners.length - 1];
break;
}
owners.length -= 1;
if (required > owners.length)
changeRequirement(owners.length);
OwnerRemoval(owner);
}
/// @dev Allows to replace an owner with a new owner. Transaction has to be sent by wallet.
/// @param owner Address of owner to be replaced.
/// @param owner Address of new owner.
function replaceOwner(address owner, address newOwner)
public
onlyWallet
ownerExists(owner)
ownerDoesNotExist(newOwner)
{
for (uint i=0; i<owners.length; i++)
if (owners[i] == owner) {
owners[i] = newOwner;
break;
}
isOwner[owner] = false;
isOwner[newOwner] = true;
OwnerRemoval(owner);
OwnerAddition(newOwner);
}
/// @dev Allows to change the number of required confirmations. Transaction has to be sent by wallet.
/// @param _required Number of required confirmations.
function changeRequirement(uint _required)
public
onlyWallet
validRequirement(owners.length, _required)
{
required = _required;
RequirementChange(_required);
}
/// @dev Allows an owner to submit and confirm a transaction.
/// @param destination Transaction target address.
/// @param value Transaction ether value.
/// @param data Transaction data payload.
/// @return Returns transaction ID.
function submitTransaction(address destination, uint value, bytes data)
public
returns (uint transactionId)
{
transactionId = addTransaction(destination, value, data);
confirmTransaction(transactionId);
}
/// @dev Allows an owner to confirm a transaction.
/// @param transactionId Transaction ID.
function confirmTransaction(uint transactionId)
public
ownerExists(msg.sender)
transactionExists(transactionId)
notConfirmed(transactionId, msg.sender)
{
confirmations[transactionId][msg.sender] = true;
Confirmation(msg.sender, transactionId);
executeTransaction(transactionId);
}
/// @dev Allows an owner to revoke a confirmation for a transaction.
/// @param transactionId Transaction ID.
function revokeConfirmation(uint transactionId)
public
ownerExists(msg.sender)
confirmed(transactionId, msg.sender)
notExecuted(transactionId)
{
confirmations[transactionId][msg.sender] = false;
Revocation(msg.sender, transactionId);
}
/// @dev Allows anyone to execute a confirmed transaction.
/// @param transactionId Transaction ID.
function executeTransaction(uint transactionId)
public
notExecuted(transactionId)
{
if (isConfirmed(transactionId)) {
Transaction tx = transactions[transactionId];
tx.executed = true;
if (tx.destination.call.value(tx.value)(tx.data))
Execution(transactionId);
else {
ExecutionFailure(transactionId);
tx.executed = false;
}
}
}
/// @dev Returns the confirmation status of a transaction.
/// @param transactionId Transaction ID.
/// @return Confirmation status.
function isConfirmed(uint transactionId)
public
constant
returns (bool)
{
uint count = 0;
for (uint i=0; i<owners.length; i++) {
if (confirmations[transactionId][owners[i]])
count += 1;
if (count == required)
return true;
}
}
/*
* Internal functions
*/
/// @dev Adds a new transaction to the transaction mapping, if transaction does not exist yet.
/// @param destination Transaction target address.
/// @param value Transaction ether value.
/// @param data Transaction data payload.
/// @return Returns transaction ID.
function addTransaction(address destination, uint value, bytes data)
internal
notNull(destination)
returns (uint transactionId)
{
transactionId = transactionCount;
transactions[transactionId] = Transaction({
destination: destination,
value: value,
data: data,
executed: false
});
transactionCount += 1;
Submission(transactionId);
}
/*
* Web3 call functions
*/
/// @dev Returns number of confirmations of a transaction.
/// @param transactionId Transaction ID.
/// @return Number of confirmations.
function getConfirmationCount(uint transactionId)
public
constant
returns (uint count)
{
for (uint i=0; i<owners.length; i++)
if (confirmations[transactionId][owners[i]])
count += 1;
}
/// @dev Returns total number of transactions after filers are applied.
/// @param pending Include pending transactions.
/// @param executed Include executed transactions.
/// @return Total number of transactions after filters are applied.
function getTransactionCount(bool pending, bool executed)
public
constant
returns (uint count)
{
for (uint i=0; i<transactionCount; i++)
if ( pending && !transactions[i].executed
|| executed && transactions[i].executed)
count += 1;
}
/// @dev Returns list of owners.
/// @return List of owner addresses.
function getOwners()
public
constant
returns (address[])
{
return owners;
}
/// @dev Returns array with owner addresses, which confirmed transaction.
/// @param transactionId Transaction ID.
/// @return Returns array of owner addresses.
function getConfirmations(uint transactionId)
public
constant
returns (address[] _confirmations)
{
address[] memory confirmationsTemp = new address[](owners.length);
uint count = 0;
uint i;
for (i=0; i<owners.length; i++)
if (confirmations[transactionId][owners[i]]) {
confirmationsTemp[count] = owners[i];
count += 1;
}
_confirmations = new address[](count);
for (i=0; i<count; i++)
_confirmations[i] = confirmationsTemp[i];
}
/// @dev Returns list of transaction IDs in defined range.
/// @param from Index start position of transaction array.
/// @param to Index end position of transaction array.
/// @param pending Include pending transactions.
/// @param executed Include executed transactions.
/// @return Returns array of transaction IDs.
function getTransactionIds(uint from, uint to, bool pending, bool executed)
public
constant
returns (uint[] _transactionIds)
{
uint[] memory transactionIdsTemp = new uint[](transactionCount);
uint count = 0;
uint i;
for (i=0; i<transactionCount; i++)
if ( pending && !transactions[i].executed
|| executed && transactions[i].executed)
{
transactionIdsTemp[count] = i;
count += 1;
}
_transactionIds = new uint[](to - from);
for (i=from; i<to; i++)
_transactionIds[i - from] = transactionIdsTemp[i];
}
/// @dev Create new coin.
function createCoin()
external
onlyWallet
{
require(flag == true);
CoinCreation(new Gifto());
flag = false;
}
} | /// @title Multisignature wallet - Allows multiple parties to agree on transactions before execution.
/// @author Stefan George - <[email protected]> | NatSpecSingleLine | function()
payable
{
if (msg.value > 0)
Deposit(msg.sender, msg.value);
}
| /// @dev Fallback function allows to deposit ether. | NatSpecSingleLine | v0.4.18+commit.9cf6e910 | bzzr://891e8485538f16f2fa5b9af11f8c795bc62d51fb6455063a6ee3652fa7680f20 | {
"func_code_index": [
2447,
2566
]
} | 3,533 |
||
MultiSigWallet | MultiSigWallet.sol | 0x615ed6779507f223d04722d43ccc0cd871964e2a | Solidity | MultiSigWallet | contract MultiSigWallet {
uint constant public MAX_OWNER_COUNT = 50;
event Confirmation(address indexed sender, uint indexed transactionId);
event Revocation(address indexed sender, uint indexed transactionId);
event Submission(uint indexed transactionId);
event Execution(uint indexed transactionId);
event ExecutionFailure(uint indexed transactionId);
event Deposit(address indexed sender, uint value);
event OwnerAddition(address indexed owner);
event OwnerRemoval(address indexed owner);
event RequirementChange(uint required);
event CoinCreation(address coin);
mapping (uint => Transaction) public transactions;
mapping (uint => mapping (address => bool)) public confirmations;
mapping (address => bool) public isOwner;
address[] public owners;
uint public required;
uint public transactionCount;
bool flag = true;
struct Transaction {
address destination;
uint value;
bytes data;
bool executed;
}
modifier onlyWallet() {
if (msg.sender != address(this))
revert();
_;
}
modifier ownerDoesNotExist(address owner) {
if (isOwner[owner])
revert();
_;
}
modifier ownerExists(address owner) {
if (!isOwner[owner])
revert();
_;
}
modifier transactionExists(uint transactionId) {
if (transactions[transactionId].destination == 0)
revert();
_;
}
modifier confirmed(uint transactionId, address owner) {
if (!confirmations[transactionId][owner])
revert();
_;
}
modifier notConfirmed(uint transactionId, address owner) {
if (confirmations[transactionId][owner])
revert();
_;
}
modifier notExecuted(uint transactionId) {
if (transactions[transactionId].executed)
revert();
_;
}
modifier notNull(address _address) {
if (_address == 0)
revert();
_;
}
modifier validRequirement(uint ownerCount, uint _required) {
if ( ownerCount > MAX_OWNER_COUNT
|| _required > ownerCount
|| _required == 0
|| ownerCount == 0)
revert();
_;
}
/// @dev Fallback function allows to deposit ether.
function()
payable
{
if (msg.value > 0)
Deposit(msg.sender, msg.value);
}
/*
* Public functions
*/
/// @dev Contract constructor sets initial owners and required number of confirmations.
/// @param _owners List of initial owners.
/// @param _required Number of required confirmations.
function MultiSigWallet(address[] _owners, uint _required)
public
validRequirement(_owners.length, _required)
{
for (uint i=0; i<_owners.length; i++) {
if (isOwner[_owners[i]] || _owners[i] == 0)
revert();
isOwner[_owners[i]] = true;
}
owners = _owners;
required = _required;
}
/// @dev Allows to add a new owner. Transaction has to be sent by wallet.
/// @param owner Address of new owner.
function addOwner(address owner)
public
onlyWallet
ownerDoesNotExist(owner)
notNull(owner)
validRequirement(owners.length + 1, required)
{
isOwner[owner] = true;
owners.push(owner);
OwnerAddition(owner);
}
/// @dev Allows to remove an owner. Transaction has to be sent by wallet.
/// @param owner Address of owner.
function removeOwner(address owner)
public
onlyWallet
ownerExists(owner)
{
isOwner[owner] = false;
for (uint i=0; i<owners.length - 1; i++)
if (owners[i] == owner) {
owners[i] = owners[owners.length - 1];
break;
}
owners.length -= 1;
if (required > owners.length)
changeRequirement(owners.length);
OwnerRemoval(owner);
}
/// @dev Allows to replace an owner with a new owner. Transaction has to be sent by wallet.
/// @param owner Address of owner to be replaced.
/// @param owner Address of new owner.
function replaceOwner(address owner, address newOwner)
public
onlyWallet
ownerExists(owner)
ownerDoesNotExist(newOwner)
{
for (uint i=0; i<owners.length; i++)
if (owners[i] == owner) {
owners[i] = newOwner;
break;
}
isOwner[owner] = false;
isOwner[newOwner] = true;
OwnerRemoval(owner);
OwnerAddition(newOwner);
}
/// @dev Allows to change the number of required confirmations. Transaction has to be sent by wallet.
/// @param _required Number of required confirmations.
function changeRequirement(uint _required)
public
onlyWallet
validRequirement(owners.length, _required)
{
required = _required;
RequirementChange(_required);
}
/// @dev Allows an owner to submit and confirm a transaction.
/// @param destination Transaction target address.
/// @param value Transaction ether value.
/// @param data Transaction data payload.
/// @return Returns transaction ID.
function submitTransaction(address destination, uint value, bytes data)
public
returns (uint transactionId)
{
transactionId = addTransaction(destination, value, data);
confirmTransaction(transactionId);
}
/// @dev Allows an owner to confirm a transaction.
/// @param transactionId Transaction ID.
function confirmTransaction(uint transactionId)
public
ownerExists(msg.sender)
transactionExists(transactionId)
notConfirmed(transactionId, msg.sender)
{
confirmations[transactionId][msg.sender] = true;
Confirmation(msg.sender, transactionId);
executeTransaction(transactionId);
}
/// @dev Allows an owner to revoke a confirmation for a transaction.
/// @param transactionId Transaction ID.
function revokeConfirmation(uint transactionId)
public
ownerExists(msg.sender)
confirmed(transactionId, msg.sender)
notExecuted(transactionId)
{
confirmations[transactionId][msg.sender] = false;
Revocation(msg.sender, transactionId);
}
/// @dev Allows anyone to execute a confirmed transaction.
/// @param transactionId Transaction ID.
function executeTransaction(uint transactionId)
public
notExecuted(transactionId)
{
if (isConfirmed(transactionId)) {
Transaction tx = transactions[transactionId];
tx.executed = true;
if (tx.destination.call.value(tx.value)(tx.data))
Execution(transactionId);
else {
ExecutionFailure(transactionId);
tx.executed = false;
}
}
}
/// @dev Returns the confirmation status of a transaction.
/// @param transactionId Transaction ID.
/// @return Confirmation status.
function isConfirmed(uint transactionId)
public
constant
returns (bool)
{
uint count = 0;
for (uint i=0; i<owners.length; i++) {
if (confirmations[transactionId][owners[i]])
count += 1;
if (count == required)
return true;
}
}
/*
* Internal functions
*/
/// @dev Adds a new transaction to the transaction mapping, if transaction does not exist yet.
/// @param destination Transaction target address.
/// @param value Transaction ether value.
/// @param data Transaction data payload.
/// @return Returns transaction ID.
function addTransaction(address destination, uint value, bytes data)
internal
notNull(destination)
returns (uint transactionId)
{
transactionId = transactionCount;
transactions[transactionId] = Transaction({
destination: destination,
value: value,
data: data,
executed: false
});
transactionCount += 1;
Submission(transactionId);
}
/*
* Web3 call functions
*/
/// @dev Returns number of confirmations of a transaction.
/// @param transactionId Transaction ID.
/// @return Number of confirmations.
function getConfirmationCount(uint transactionId)
public
constant
returns (uint count)
{
for (uint i=0; i<owners.length; i++)
if (confirmations[transactionId][owners[i]])
count += 1;
}
/// @dev Returns total number of transactions after filers are applied.
/// @param pending Include pending transactions.
/// @param executed Include executed transactions.
/// @return Total number of transactions after filters are applied.
function getTransactionCount(bool pending, bool executed)
public
constant
returns (uint count)
{
for (uint i=0; i<transactionCount; i++)
if ( pending && !transactions[i].executed
|| executed && transactions[i].executed)
count += 1;
}
/// @dev Returns list of owners.
/// @return List of owner addresses.
function getOwners()
public
constant
returns (address[])
{
return owners;
}
/// @dev Returns array with owner addresses, which confirmed transaction.
/// @param transactionId Transaction ID.
/// @return Returns array of owner addresses.
function getConfirmations(uint transactionId)
public
constant
returns (address[] _confirmations)
{
address[] memory confirmationsTemp = new address[](owners.length);
uint count = 0;
uint i;
for (i=0; i<owners.length; i++)
if (confirmations[transactionId][owners[i]]) {
confirmationsTemp[count] = owners[i];
count += 1;
}
_confirmations = new address[](count);
for (i=0; i<count; i++)
_confirmations[i] = confirmationsTemp[i];
}
/// @dev Returns list of transaction IDs in defined range.
/// @param from Index start position of transaction array.
/// @param to Index end position of transaction array.
/// @param pending Include pending transactions.
/// @param executed Include executed transactions.
/// @return Returns array of transaction IDs.
function getTransactionIds(uint from, uint to, bool pending, bool executed)
public
constant
returns (uint[] _transactionIds)
{
uint[] memory transactionIdsTemp = new uint[](transactionCount);
uint count = 0;
uint i;
for (i=0; i<transactionCount; i++)
if ( pending && !transactions[i].executed
|| executed && transactions[i].executed)
{
transactionIdsTemp[count] = i;
count += 1;
}
_transactionIds = new uint[](to - from);
for (i=from; i<to; i++)
_transactionIds[i - from] = transactionIdsTemp[i];
}
/// @dev Create new coin.
function createCoin()
external
onlyWallet
{
require(flag == true);
CoinCreation(new Gifto());
flag = false;
}
} | /// @title Multisignature wallet - Allows multiple parties to agree on transactions before execution.
/// @author Stefan George - <[email protected]> | NatSpecSingleLine | MultiSigWallet | function MultiSigWallet(address[] _owners, uint _required)
public
validRequirement(_owners.length, _required)
{
for (uint i=0; i<_owners.length; i++) {
if (isOwner[_owners[i]] || _owners[i] == 0)
revert();
isOwner[_owners[i]] = true;
}
owners = _owners;
required = _required;
}
| /// @dev Contract constructor sets initial owners and required number of confirmations.
/// @param _owners List of initial owners.
/// @param _required Number of required confirmations. | NatSpecSingleLine | v0.4.18+commit.9cf6e910 | bzzr://891e8485538f16f2fa5b9af11f8c795bc62d51fb6455063a6ee3652fa7680f20 | {
"func_code_index": [
2812,
3201
]
} | 3,534 |
|
MultiSigWallet | MultiSigWallet.sol | 0x615ed6779507f223d04722d43ccc0cd871964e2a | Solidity | MultiSigWallet | contract MultiSigWallet {
uint constant public MAX_OWNER_COUNT = 50;
event Confirmation(address indexed sender, uint indexed transactionId);
event Revocation(address indexed sender, uint indexed transactionId);
event Submission(uint indexed transactionId);
event Execution(uint indexed transactionId);
event ExecutionFailure(uint indexed transactionId);
event Deposit(address indexed sender, uint value);
event OwnerAddition(address indexed owner);
event OwnerRemoval(address indexed owner);
event RequirementChange(uint required);
event CoinCreation(address coin);
mapping (uint => Transaction) public transactions;
mapping (uint => mapping (address => bool)) public confirmations;
mapping (address => bool) public isOwner;
address[] public owners;
uint public required;
uint public transactionCount;
bool flag = true;
struct Transaction {
address destination;
uint value;
bytes data;
bool executed;
}
modifier onlyWallet() {
if (msg.sender != address(this))
revert();
_;
}
modifier ownerDoesNotExist(address owner) {
if (isOwner[owner])
revert();
_;
}
modifier ownerExists(address owner) {
if (!isOwner[owner])
revert();
_;
}
modifier transactionExists(uint transactionId) {
if (transactions[transactionId].destination == 0)
revert();
_;
}
modifier confirmed(uint transactionId, address owner) {
if (!confirmations[transactionId][owner])
revert();
_;
}
modifier notConfirmed(uint transactionId, address owner) {
if (confirmations[transactionId][owner])
revert();
_;
}
modifier notExecuted(uint transactionId) {
if (transactions[transactionId].executed)
revert();
_;
}
modifier notNull(address _address) {
if (_address == 0)
revert();
_;
}
modifier validRequirement(uint ownerCount, uint _required) {
if ( ownerCount > MAX_OWNER_COUNT
|| _required > ownerCount
|| _required == 0
|| ownerCount == 0)
revert();
_;
}
/// @dev Fallback function allows to deposit ether.
function()
payable
{
if (msg.value > 0)
Deposit(msg.sender, msg.value);
}
/*
* Public functions
*/
/// @dev Contract constructor sets initial owners and required number of confirmations.
/// @param _owners List of initial owners.
/// @param _required Number of required confirmations.
function MultiSigWallet(address[] _owners, uint _required)
public
validRequirement(_owners.length, _required)
{
for (uint i=0; i<_owners.length; i++) {
if (isOwner[_owners[i]] || _owners[i] == 0)
revert();
isOwner[_owners[i]] = true;
}
owners = _owners;
required = _required;
}
/// @dev Allows to add a new owner. Transaction has to be sent by wallet.
/// @param owner Address of new owner.
function addOwner(address owner)
public
onlyWallet
ownerDoesNotExist(owner)
notNull(owner)
validRequirement(owners.length + 1, required)
{
isOwner[owner] = true;
owners.push(owner);
OwnerAddition(owner);
}
/// @dev Allows to remove an owner. Transaction has to be sent by wallet.
/// @param owner Address of owner.
function removeOwner(address owner)
public
onlyWallet
ownerExists(owner)
{
isOwner[owner] = false;
for (uint i=0; i<owners.length - 1; i++)
if (owners[i] == owner) {
owners[i] = owners[owners.length - 1];
break;
}
owners.length -= 1;
if (required > owners.length)
changeRequirement(owners.length);
OwnerRemoval(owner);
}
/// @dev Allows to replace an owner with a new owner. Transaction has to be sent by wallet.
/// @param owner Address of owner to be replaced.
/// @param owner Address of new owner.
function replaceOwner(address owner, address newOwner)
public
onlyWallet
ownerExists(owner)
ownerDoesNotExist(newOwner)
{
for (uint i=0; i<owners.length; i++)
if (owners[i] == owner) {
owners[i] = newOwner;
break;
}
isOwner[owner] = false;
isOwner[newOwner] = true;
OwnerRemoval(owner);
OwnerAddition(newOwner);
}
/// @dev Allows to change the number of required confirmations. Transaction has to be sent by wallet.
/// @param _required Number of required confirmations.
function changeRequirement(uint _required)
public
onlyWallet
validRequirement(owners.length, _required)
{
required = _required;
RequirementChange(_required);
}
/// @dev Allows an owner to submit and confirm a transaction.
/// @param destination Transaction target address.
/// @param value Transaction ether value.
/// @param data Transaction data payload.
/// @return Returns transaction ID.
function submitTransaction(address destination, uint value, bytes data)
public
returns (uint transactionId)
{
transactionId = addTransaction(destination, value, data);
confirmTransaction(transactionId);
}
/// @dev Allows an owner to confirm a transaction.
/// @param transactionId Transaction ID.
function confirmTransaction(uint transactionId)
public
ownerExists(msg.sender)
transactionExists(transactionId)
notConfirmed(transactionId, msg.sender)
{
confirmations[transactionId][msg.sender] = true;
Confirmation(msg.sender, transactionId);
executeTransaction(transactionId);
}
/// @dev Allows an owner to revoke a confirmation for a transaction.
/// @param transactionId Transaction ID.
function revokeConfirmation(uint transactionId)
public
ownerExists(msg.sender)
confirmed(transactionId, msg.sender)
notExecuted(transactionId)
{
confirmations[transactionId][msg.sender] = false;
Revocation(msg.sender, transactionId);
}
/// @dev Allows anyone to execute a confirmed transaction.
/// @param transactionId Transaction ID.
function executeTransaction(uint transactionId)
public
notExecuted(transactionId)
{
if (isConfirmed(transactionId)) {
Transaction tx = transactions[transactionId];
tx.executed = true;
if (tx.destination.call.value(tx.value)(tx.data))
Execution(transactionId);
else {
ExecutionFailure(transactionId);
tx.executed = false;
}
}
}
/// @dev Returns the confirmation status of a transaction.
/// @param transactionId Transaction ID.
/// @return Confirmation status.
function isConfirmed(uint transactionId)
public
constant
returns (bool)
{
uint count = 0;
for (uint i=0; i<owners.length; i++) {
if (confirmations[transactionId][owners[i]])
count += 1;
if (count == required)
return true;
}
}
/*
* Internal functions
*/
/// @dev Adds a new transaction to the transaction mapping, if transaction does not exist yet.
/// @param destination Transaction target address.
/// @param value Transaction ether value.
/// @param data Transaction data payload.
/// @return Returns transaction ID.
function addTransaction(address destination, uint value, bytes data)
internal
notNull(destination)
returns (uint transactionId)
{
transactionId = transactionCount;
transactions[transactionId] = Transaction({
destination: destination,
value: value,
data: data,
executed: false
});
transactionCount += 1;
Submission(transactionId);
}
/*
* Web3 call functions
*/
/// @dev Returns number of confirmations of a transaction.
/// @param transactionId Transaction ID.
/// @return Number of confirmations.
function getConfirmationCount(uint transactionId)
public
constant
returns (uint count)
{
for (uint i=0; i<owners.length; i++)
if (confirmations[transactionId][owners[i]])
count += 1;
}
/// @dev Returns total number of transactions after filers are applied.
/// @param pending Include pending transactions.
/// @param executed Include executed transactions.
/// @return Total number of transactions after filters are applied.
function getTransactionCount(bool pending, bool executed)
public
constant
returns (uint count)
{
for (uint i=0; i<transactionCount; i++)
if ( pending && !transactions[i].executed
|| executed && transactions[i].executed)
count += 1;
}
/// @dev Returns list of owners.
/// @return List of owner addresses.
function getOwners()
public
constant
returns (address[])
{
return owners;
}
/// @dev Returns array with owner addresses, which confirmed transaction.
/// @param transactionId Transaction ID.
/// @return Returns array of owner addresses.
function getConfirmations(uint transactionId)
public
constant
returns (address[] _confirmations)
{
address[] memory confirmationsTemp = new address[](owners.length);
uint count = 0;
uint i;
for (i=0; i<owners.length; i++)
if (confirmations[transactionId][owners[i]]) {
confirmationsTemp[count] = owners[i];
count += 1;
}
_confirmations = new address[](count);
for (i=0; i<count; i++)
_confirmations[i] = confirmationsTemp[i];
}
/// @dev Returns list of transaction IDs in defined range.
/// @param from Index start position of transaction array.
/// @param to Index end position of transaction array.
/// @param pending Include pending transactions.
/// @param executed Include executed transactions.
/// @return Returns array of transaction IDs.
function getTransactionIds(uint from, uint to, bool pending, bool executed)
public
constant
returns (uint[] _transactionIds)
{
uint[] memory transactionIdsTemp = new uint[](transactionCount);
uint count = 0;
uint i;
for (i=0; i<transactionCount; i++)
if ( pending && !transactions[i].executed
|| executed && transactions[i].executed)
{
transactionIdsTemp[count] = i;
count += 1;
}
_transactionIds = new uint[](to - from);
for (i=from; i<to; i++)
_transactionIds[i - from] = transactionIdsTemp[i];
}
/// @dev Create new coin.
function createCoin()
external
onlyWallet
{
require(flag == true);
CoinCreation(new Gifto());
flag = false;
}
} | /// @title Multisignature wallet - Allows multiple parties to agree on transactions before execution.
/// @author Stefan George - <[email protected]> | NatSpecSingleLine | addOwner | function addOwner(address owner)
public
onlyWallet
ownerDoesNotExist(owner)
notNull(owner)
validRequirement(owners.length + 1, required)
{
isOwner[owner] = true;
owners.push(owner);
OwnerAddition(owner);
}
| /// @dev Allows to add a new owner. Transaction has to be sent by wallet.
/// @param owner Address of new owner. | NatSpecSingleLine | v0.4.18+commit.9cf6e910 | bzzr://891e8485538f16f2fa5b9af11f8c795bc62d51fb6455063a6ee3652fa7680f20 | {
"func_code_index": [
3327,
3619
]
} | 3,535 |
|
MultiSigWallet | MultiSigWallet.sol | 0x615ed6779507f223d04722d43ccc0cd871964e2a | Solidity | MultiSigWallet | contract MultiSigWallet {
uint constant public MAX_OWNER_COUNT = 50;
event Confirmation(address indexed sender, uint indexed transactionId);
event Revocation(address indexed sender, uint indexed transactionId);
event Submission(uint indexed transactionId);
event Execution(uint indexed transactionId);
event ExecutionFailure(uint indexed transactionId);
event Deposit(address indexed sender, uint value);
event OwnerAddition(address indexed owner);
event OwnerRemoval(address indexed owner);
event RequirementChange(uint required);
event CoinCreation(address coin);
mapping (uint => Transaction) public transactions;
mapping (uint => mapping (address => bool)) public confirmations;
mapping (address => bool) public isOwner;
address[] public owners;
uint public required;
uint public transactionCount;
bool flag = true;
struct Transaction {
address destination;
uint value;
bytes data;
bool executed;
}
modifier onlyWallet() {
if (msg.sender != address(this))
revert();
_;
}
modifier ownerDoesNotExist(address owner) {
if (isOwner[owner])
revert();
_;
}
modifier ownerExists(address owner) {
if (!isOwner[owner])
revert();
_;
}
modifier transactionExists(uint transactionId) {
if (transactions[transactionId].destination == 0)
revert();
_;
}
modifier confirmed(uint transactionId, address owner) {
if (!confirmations[transactionId][owner])
revert();
_;
}
modifier notConfirmed(uint transactionId, address owner) {
if (confirmations[transactionId][owner])
revert();
_;
}
modifier notExecuted(uint transactionId) {
if (transactions[transactionId].executed)
revert();
_;
}
modifier notNull(address _address) {
if (_address == 0)
revert();
_;
}
modifier validRequirement(uint ownerCount, uint _required) {
if ( ownerCount > MAX_OWNER_COUNT
|| _required > ownerCount
|| _required == 0
|| ownerCount == 0)
revert();
_;
}
/// @dev Fallback function allows to deposit ether.
function()
payable
{
if (msg.value > 0)
Deposit(msg.sender, msg.value);
}
/*
* Public functions
*/
/// @dev Contract constructor sets initial owners and required number of confirmations.
/// @param _owners List of initial owners.
/// @param _required Number of required confirmations.
function MultiSigWallet(address[] _owners, uint _required)
public
validRequirement(_owners.length, _required)
{
for (uint i=0; i<_owners.length; i++) {
if (isOwner[_owners[i]] || _owners[i] == 0)
revert();
isOwner[_owners[i]] = true;
}
owners = _owners;
required = _required;
}
/// @dev Allows to add a new owner. Transaction has to be sent by wallet.
/// @param owner Address of new owner.
function addOwner(address owner)
public
onlyWallet
ownerDoesNotExist(owner)
notNull(owner)
validRequirement(owners.length + 1, required)
{
isOwner[owner] = true;
owners.push(owner);
OwnerAddition(owner);
}
/// @dev Allows to remove an owner. Transaction has to be sent by wallet.
/// @param owner Address of owner.
function removeOwner(address owner)
public
onlyWallet
ownerExists(owner)
{
isOwner[owner] = false;
for (uint i=0; i<owners.length - 1; i++)
if (owners[i] == owner) {
owners[i] = owners[owners.length - 1];
break;
}
owners.length -= 1;
if (required > owners.length)
changeRequirement(owners.length);
OwnerRemoval(owner);
}
/// @dev Allows to replace an owner with a new owner. Transaction has to be sent by wallet.
/// @param owner Address of owner to be replaced.
/// @param owner Address of new owner.
function replaceOwner(address owner, address newOwner)
public
onlyWallet
ownerExists(owner)
ownerDoesNotExist(newOwner)
{
for (uint i=0; i<owners.length; i++)
if (owners[i] == owner) {
owners[i] = newOwner;
break;
}
isOwner[owner] = false;
isOwner[newOwner] = true;
OwnerRemoval(owner);
OwnerAddition(newOwner);
}
/// @dev Allows to change the number of required confirmations. Transaction has to be sent by wallet.
/// @param _required Number of required confirmations.
function changeRequirement(uint _required)
public
onlyWallet
validRequirement(owners.length, _required)
{
required = _required;
RequirementChange(_required);
}
/// @dev Allows an owner to submit and confirm a transaction.
/// @param destination Transaction target address.
/// @param value Transaction ether value.
/// @param data Transaction data payload.
/// @return Returns transaction ID.
function submitTransaction(address destination, uint value, bytes data)
public
returns (uint transactionId)
{
transactionId = addTransaction(destination, value, data);
confirmTransaction(transactionId);
}
/// @dev Allows an owner to confirm a transaction.
/// @param transactionId Transaction ID.
function confirmTransaction(uint transactionId)
public
ownerExists(msg.sender)
transactionExists(transactionId)
notConfirmed(transactionId, msg.sender)
{
confirmations[transactionId][msg.sender] = true;
Confirmation(msg.sender, transactionId);
executeTransaction(transactionId);
}
/// @dev Allows an owner to revoke a confirmation for a transaction.
/// @param transactionId Transaction ID.
function revokeConfirmation(uint transactionId)
public
ownerExists(msg.sender)
confirmed(transactionId, msg.sender)
notExecuted(transactionId)
{
confirmations[transactionId][msg.sender] = false;
Revocation(msg.sender, transactionId);
}
/// @dev Allows anyone to execute a confirmed transaction.
/// @param transactionId Transaction ID.
function executeTransaction(uint transactionId)
public
notExecuted(transactionId)
{
if (isConfirmed(transactionId)) {
Transaction tx = transactions[transactionId];
tx.executed = true;
if (tx.destination.call.value(tx.value)(tx.data))
Execution(transactionId);
else {
ExecutionFailure(transactionId);
tx.executed = false;
}
}
}
/// @dev Returns the confirmation status of a transaction.
/// @param transactionId Transaction ID.
/// @return Confirmation status.
function isConfirmed(uint transactionId)
public
constant
returns (bool)
{
uint count = 0;
for (uint i=0; i<owners.length; i++) {
if (confirmations[transactionId][owners[i]])
count += 1;
if (count == required)
return true;
}
}
/*
* Internal functions
*/
/// @dev Adds a new transaction to the transaction mapping, if transaction does not exist yet.
/// @param destination Transaction target address.
/// @param value Transaction ether value.
/// @param data Transaction data payload.
/// @return Returns transaction ID.
function addTransaction(address destination, uint value, bytes data)
internal
notNull(destination)
returns (uint transactionId)
{
transactionId = transactionCount;
transactions[transactionId] = Transaction({
destination: destination,
value: value,
data: data,
executed: false
});
transactionCount += 1;
Submission(transactionId);
}
/*
* Web3 call functions
*/
/// @dev Returns number of confirmations of a transaction.
/// @param transactionId Transaction ID.
/// @return Number of confirmations.
function getConfirmationCount(uint transactionId)
public
constant
returns (uint count)
{
for (uint i=0; i<owners.length; i++)
if (confirmations[transactionId][owners[i]])
count += 1;
}
/// @dev Returns total number of transactions after filers are applied.
/// @param pending Include pending transactions.
/// @param executed Include executed transactions.
/// @return Total number of transactions after filters are applied.
function getTransactionCount(bool pending, bool executed)
public
constant
returns (uint count)
{
for (uint i=0; i<transactionCount; i++)
if ( pending && !transactions[i].executed
|| executed && transactions[i].executed)
count += 1;
}
/// @dev Returns list of owners.
/// @return List of owner addresses.
function getOwners()
public
constant
returns (address[])
{
return owners;
}
/// @dev Returns array with owner addresses, which confirmed transaction.
/// @param transactionId Transaction ID.
/// @return Returns array of owner addresses.
function getConfirmations(uint transactionId)
public
constant
returns (address[] _confirmations)
{
address[] memory confirmationsTemp = new address[](owners.length);
uint count = 0;
uint i;
for (i=0; i<owners.length; i++)
if (confirmations[transactionId][owners[i]]) {
confirmationsTemp[count] = owners[i];
count += 1;
}
_confirmations = new address[](count);
for (i=0; i<count; i++)
_confirmations[i] = confirmationsTemp[i];
}
/// @dev Returns list of transaction IDs in defined range.
/// @param from Index start position of transaction array.
/// @param to Index end position of transaction array.
/// @param pending Include pending transactions.
/// @param executed Include executed transactions.
/// @return Returns array of transaction IDs.
function getTransactionIds(uint from, uint to, bool pending, bool executed)
public
constant
returns (uint[] _transactionIds)
{
uint[] memory transactionIdsTemp = new uint[](transactionCount);
uint count = 0;
uint i;
for (i=0; i<transactionCount; i++)
if ( pending && !transactions[i].executed
|| executed && transactions[i].executed)
{
transactionIdsTemp[count] = i;
count += 1;
}
_transactionIds = new uint[](to - from);
for (i=from; i<to; i++)
_transactionIds[i - from] = transactionIdsTemp[i];
}
/// @dev Create new coin.
function createCoin()
external
onlyWallet
{
require(flag == true);
CoinCreation(new Gifto());
flag = false;
}
} | /// @title Multisignature wallet - Allows multiple parties to agree on transactions before execution.
/// @author Stefan George - <[email protected]> | NatSpecSingleLine | removeOwner | function removeOwner(address owner)
public
onlyWallet
ownerExists(owner)
{
isOwner[owner] = false;
for (uint i=0; i<owners.length - 1; i++)
if (owners[i] == owner) {
owners[i] = owners[owners.length - 1];
break;
}
owners.length -= 1;
if (required > owners.length)
changeRequirement(owners.length);
OwnerRemoval(owner);
}
| /// @dev Allows to remove an owner. Transaction has to be sent by wallet.
/// @param owner Address of owner. | NatSpecSingleLine | v0.4.18+commit.9cf6e910 | bzzr://891e8485538f16f2fa5b9af11f8c795bc62d51fb6455063a6ee3652fa7680f20 | {
"func_code_index": [
3741,
4221
]
} | 3,536 |
|
MultiSigWallet | MultiSigWallet.sol | 0x615ed6779507f223d04722d43ccc0cd871964e2a | Solidity | MultiSigWallet | contract MultiSigWallet {
uint constant public MAX_OWNER_COUNT = 50;
event Confirmation(address indexed sender, uint indexed transactionId);
event Revocation(address indexed sender, uint indexed transactionId);
event Submission(uint indexed transactionId);
event Execution(uint indexed transactionId);
event ExecutionFailure(uint indexed transactionId);
event Deposit(address indexed sender, uint value);
event OwnerAddition(address indexed owner);
event OwnerRemoval(address indexed owner);
event RequirementChange(uint required);
event CoinCreation(address coin);
mapping (uint => Transaction) public transactions;
mapping (uint => mapping (address => bool)) public confirmations;
mapping (address => bool) public isOwner;
address[] public owners;
uint public required;
uint public transactionCount;
bool flag = true;
struct Transaction {
address destination;
uint value;
bytes data;
bool executed;
}
modifier onlyWallet() {
if (msg.sender != address(this))
revert();
_;
}
modifier ownerDoesNotExist(address owner) {
if (isOwner[owner])
revert();
_;
}
modifier ownerExists(address owner) {
if (!isOwner[owner])
revert();
_;
}
modifier transactionExists(uint transactionId) {
if (transactions[transactionId].destination == 0)
revert();
_;
}
modifier confirmed(uint transactionId, address owner) {
if (!confirmations[transactionId][owner])
revert();
_;
}
modifier notConfirmed(uint transactionId, address owner) {
if (confirmations[transactionId][owner])
revert();
_;
}
modifier notExecuted(uint transactionId) {
if (transactions[transactionId].executed)
revert();
_;
}
modifier notNull(address _address) {
if (_address == 0)
revert();
_;
}
modifier validRequirement(uint ownerCount, uint _required) {
if ( ownerCount > MAX_OWNER_COUNT
|| _required > ownerCount
|| _required == 0
|| ownerCount == 0)
revert();
_;
}
/// @dev Fallback function allows to deposit ether.
function()
payable
{
if (msg.value > 0)
Deposit(msg.sender, msg.value);
}
/*
* Public functions
*/
/// @dev Contract constructor sets initial owners and required number of confirmations.
/// @param _owners List of initial owners.
/// @param _required Number of required confirmations.
function MultiSigWallet(address[] _owners, uint _required)
public
validRequirement(_owners.length, _required)
{
for (uint i=0; i<_owners.length; i++) {
if (isOwner[_owners[i]] || _owners[i] == 0)
revert();
isOwner[_owners[i]] = true;
}
owners = _owners;
required = _required;
}
/// @dev Allows to add a new owner. Transaction has to be sent by wallet.
/// @param owner Address of new owner.
function addOwner(address owner)
public
onlyWallet
ownerDoesNotExist(owner)
notNull(owner)
validRequirement(owners.length + 1, required)
{
isOwner[owner] = true;
owners.push(owner);
OwnerAddition(owner);
}
/// @dev Allows to remove an owner. Transaction has to be sent by wallet.
/// @param owner Address of owner.
function removeOwner(address owner)
public
onlyWallet
ownerExists(owner)
{
isOwner[owner] = false;
for (uint i=0; i<owners.length - 1; i++)
if (owners[i] == owner) {
owners[i] = owners[owners.length - 1];
break;
}
owners.length -= 1;
if (required > owners.length)
changeRequirement(owners.length);
OwnerRemoval(owner);
}
/// @dev Allows to replace an owner with a new owner. Transaction has to be sent by wallet.
/// @param owner Address of owner to be replaced.
/// @param owner Address of new owner.
function replaceOwner(address owner, address newOwner)
public
onlyWallet
ownerExists(owner)
ownerDoesNotExist(newOwner)
{
for (uint i=0; i<owners.length; i++)
if (owners[i] == owner) {
owners[i] = newOwner;
break;
}
isOwner[owner] = false;
isOwner[newOwner] = true;
OwnerRemoval(owner);
OwnerAddition(newOwner);
}
/// @dev Allows to change the number of required confirmations. Transaction has to be sent by wallet.
/// @param _required Number of required confirmations.
function changeRequirement(uint _required)
public
onlyWallet
validRequirement(owners.length, _required)
{
required = _required;
RequirementChange(_required);
}
/// @dev Allows an owner to submit and confirm a transaction.
/// @param destination Transaction target address.
/// @param value Transaction ether value.
/// @param data Transaction data payload.
/// @return Returns transaction ID.
function submitTransaction(address destination, uint value, bytes data)
public
returns (uint transactionId)
{
transactionId = addTransaction(destination, value, data);
confirmTransaction(transactionId);
}
/// @dev Allows an owner to confirm a transaction.
/// @param transactionId Transaction ID.
function confirmTransaction(uint transactionId)
public
ownerExists(msg.sender)
transactionExists(transactionId)
notConfirmed(transactionId, msg.sender)
{
confirmations[transactionId][msg.sender] = true;
Confirmation(msg.sender, transactionId);
executeTransaction(transactionId);
}
/// @dev Allows an owner to revoke a confirmation for a transaction.
/// @param transactionId Transaction ID.
function revokeConfirmation(uint transactionId)
public
ownerExists(msg.sender)
confirmed(transactionId, msg.sender)
notExecuted(transactionId)
{
confirmations[transactionId][msg.sender] = false;
Revocation(msg.sender, transactionId);
}
/// @dev Allows anyone to execute a confirmed transaction.
/// @param transactionId Transaction ID.
function executeTransaction(uint transactionId)
public
notExecuted(transactionId)
{
if (isConfirmed(transactionId)) {
Transaction tx = transactions[transactionId];
tx.executed = true;
if (tx.destination.call.value(tx.value)(tx.data))
Execution(transactionId);
else {
ExecutionFailure(transactionId);
tx.executed = false;
}
}
}
/// @dev Returns the confirmation status of a transaction.
/// @param transactionId Transaction ID.
/// @return Confirmation status.
function isConfirmed(uint transactionId)
public
constant
returns (bool)
{
uint count = 0;
for (uint i=0; i<owners.length; i++) {
if (confirmations[transactionId][owners[i]])
count += 1;
if (count == required)
return true;
}
}
/*
* Internal functions
*/
/// @dev Adds a new transaction to the transaction mapping, if transaction does not exist yet.
/// @param destination Transaction target address.
/// @param value Transaction ether value.
/// @param data Transaction data payload.
/// @return Returns transaction ID.
function addTransaction(address destination, uint value, bytes data)
internal
notNull(destination)
returns (uint transactionId)
{
transactionId = transactionCount;
transactions[transactionId] = Transaction({
destination: destination,
value: value,
data: data,
executed: false
});
transactionCount += 1;
Submission(transactionId);
}
/*
* Web3 call functions
*/
/// @dev Returns number of confirmations of a transaction.
/// @param transactionId Transaction ID.
/// @return Number of confirmations.
function getConfirmationCount(uint transactionId)
public
constant
returns (uint count)
{
for (uint i=0; i<owners.length; i++)
if (confirmations[transactionId][owners[i]])
count += 1;
}
/// @dev Returns total number of transactions after filers are applied.
/// @param pending Include pending transactions.
/// @param executed Include executed transactions.
/// @return Total number of transactions after filters are applied.
function getTransactionCount(bool pending, bool executed)
public
constant
returns (uint count)
{
for (uint i=0; i<transactionCount; i++)
if ( pending && !transactions[i].executed
|| executed && transactions[i].executed)
count += 1;
}
/// @dev Returns list of owners.
/// @return List of owner addresses.
function getOwners()
public
constant
returns (address[])
{
return owners;
}
/// @dev Returns array with owner addresses, which confirmed transaction.
/// @param transactionId Transaction ID.
/// @return Returns array of owner addresses.
function getConfirmations(uint transactionId)
public
constant
returns (address[] _confirmations)
{
address[] memory confirmationsTemp = new address[](owners.length);
uint count = 0;
uint i;
for (i=0; i<owners.length; i++)
if (confirmations[transactionId][owners[i]]) {
confirmationsTemp[count] = owners[i];
count += 1;
}
_confirmations = new address[](count);
for (i=0; i<count; i++)
_confirmations[i] = confirmationsTemp[i];
}
/// @dev Returns list of transaction IDs in defined range.
/// @param from Index start position of transaction array.
/// @param to Index end position of transaction array.
/// @param pending Include pending transactions.
/// @param executed Include executed transactions.
/// @return Returns array of transaction IDs.
function getTransactionIds(uint from, uint to, bool pending, bool executed)
public
constant
returns (uint[] _transactionIds)
{
uint[] memory transactionIdsTemp = new uint[](transactionCount);
uint count = 0;
uint i;
for (i=0; i<transactionCount; i++)
if ( pending && !transactions[i].executed
|| executed && transactions[i].executed)
{
transactionIdsTemp[count] = i;
count += 1;
}
_transactionIds = new uint[](to - from);
for (i=from; i<to; i++)
_transactionIds[i - from] = transactionIdsTemp[i];
}
/// @dev Create new coin.
function createCoin()
external
onlyWallet
{
require(flag == true);
CoinCreation(new Gifto());
flag = false;
}
} | /// @title Multisignature wallet - Allows multiple parties to agree on transactions before execution.
/// @author Stefan George - <[email protected]> | NatSpecSingleLine | replaceOwner | function replaceOwner(address owner, address newOwner)
public
onlyWallet
ownerExists(owner)
ownerDoesNotExist(newOwner)
{
for (uint i=0; i<owners.length; i++)
if (owners[i] == owner) {
owners[i] = newOwner;
break;
}
isOwner[owner] = false;
isOwner[newOwner] = true;
OwnerRemoval(owner);
OwnerAddition(newOwner);
}
| /// @dev Allows to replace an owner with a new owner. Transaction has to be sent by wallet.
/// @param owner Address of owner to be replaced.
/// @param owner Address of new owner. | NatSpecSingleLine | v0.4.18+commit.9cf6e910 | bzzr://891e8485538f16f2fa5b9af11f8c795bc62d51fb6455063a6ee3652fa7680f20 | {
"func_code_index": [
4420,
4889
]
} | 3,537 |
|
MultiSigWallet | MultiSigWallet.sol | 0x615ed6779507f223d04722d43ccc0cd871964e2a | Solidity | MultiSigWallet | contract MultiSigWallet {
uint constant public MAX_OWNER_COUNT = 50;
event Confirmation(address indexed sender, uint indexed transactionId);
event Revocation(address indexed sender, uint indexed transactionId);
event Submission(uint indexed transactionId);
event Execution(uint indexed transactionId);
event ExecutionFailure(uint indexed transactionId);
event Deposit(address indexed sender, uint value);
event OwnerAddition(address indexed owner);
event OwnerRemoval(address indexed owner);
event RequirementChange(uint required);
event CoinCreation(address coin);
mapping (uint => Transaction) public transactions;
mapping (uint => mapping (address => bool)) public confirmations;
mapping (address => bool) public isOwner;
address[] public owners;
uint public required;
uint public transactionCount;
bool flag = true;
struct Transaction {
address destination;
uint value;
bytes data;
bool executed;
}
modifier onlyWallet() {
if (msg.sender != address(this))
revert();
_;
}
modifier ownerDoesNotExist(address owner) {
if (isOwner[owner])
revert();
_;
}
modifier ownerExists(address owner) {
if (!isOwner[owner])
revert();
_;
}
modifier transactionExists(uint transactionId) {
if (transactions[transactionId].destination == 0)
revert();
_;
}
modifier confirmed(uint transactionId, address owner) {
if (!confirmations[transactionId][owner])
revert();
_;
}
modifier notConfirmed(uint transactionId, address owner) {
if (confirmations[transactionId][owner])
revert();
_;
}
modifier notExecuted(uint transactionId) {
if (transactions[transactionId].executed)
revert();
_;
}
modifier notNull(address _address) {
if (_address == 0)
revert();
_;
}
modifier validRequirement(uint ownerCount, uint _required) {
if ( ownerCount > MAX_OWNER_COUNT
|| _required > ownerCount
|| _required == 0
|| ownerCount == 0)
revert();
_;
}
/// @dev Fallback function allows to deposit ether.
function()
payable
{
if (msg.value > 0)
Deposit(msg.sender, msg.value);
}
/*
* Public functions
*/
/// @dev Contract constructor sets initial owners and required number of confirmations.
/// @param _owners List of initial owners.
/// @param _required Number of required confirmations.
function MultiSigWallet(address[] _owners, uint _required)
public
validRequirement(_owners.length, _required)
{
for (uint i=0; i<_owners.length; i++) {
if (isOwner[_owners[i]] || _owners[i] == 0)
revert();
isOwner[_owners[i]] = true;
}
owners = _owners;
required = _required;
}
/// @dev Allows to add a new owner. Transaction has to be sent by wallet.
/// @param owner Address of new owner.
function addOwner(address owner)
public
onlyWallet
ownerDoesNotExist(owner)
notNull(owner)
validRequirement(owners.length + 1, required)
{
isOwner[owner] = true;
owners.push(owner);
OwnerAddition(owner);
}
/// @dev Allows to remove an owner. Transaction has to be sent by wallet.
/// @param owner Address of owner.
function removeOwner(address owner)
public
onlyWallet
ownerExists(owner)
{
isOwner[owner] = false;
for (uint i=0; i<owners.length - 1; i++)
if (owners[i] == owner) {
owners[i] = owners[owners.length - 1];
break;
}
owners.length -= 1;
if (required > owners.length)
changeRequirement(owners.length);
OwnerRemoval(owner);
}
/// @dev Allows to replace an owner with a new owner. Transaction has to be sent by wallet.
/// @param owner Address of owner to be replaced.
/// @param owner Address of new owner.
function replaceOwner(address owner, address newOwner)
public
onlyWallet
ownerExists(owner)
ownerDoesNotExist(newOwner)
{
for (uint i=0; i<owners.length; i++)
if (owners[i] == owner) {
owners[i] = newOwner;
break;
}
isOwner[owner] = false;
isOwner[newOwner] = true;
OwnerRemoval(owner);
OwnerAddition(newOwner);
}
/// @dev Allows to change the number of required confirmations. Transaction has to be sent by wallet.
/// @param _required Number of required confirmations.
function changeRequirement(uint _required)
public
onlyWallet
validRequirement(owners.length, _required)
{
required = _required;
RequirementChange(_required);
}
/// @dev Allows an owner to submit and confirm a transaction.
/// @param destination Transaction target address.
/// @param value Transaction ether value.
/// @param data Transaction data payload.
/// @return Returns transaction ID.
function submitTransaction(address destination, uint value, bytes data)
public
returns (uint transactionId)
{
transactionId = addTransaction(destination, value, data);
confirmTransaction(transactionId);
}
/// @dev Allows an owner to confirm a transaction.
/// @param transactionId Transaction ID.
function confirmTransaction(uint transactionId)
public
ownerExists(msg.sender)
transactionExists(transactionId)
notConfirmed(transactionId, msg.sender)
{
confirmations[transactionId][msg.sender] = true;
Confirmation(msg.sender, transactionId);
executeTransaction(transactionId);
}
/// @dev Allows an owner to revoke a confirmation for a transaction.
/// @param transactionId Transaction ID.
function revokeConfirmation(uint transactionId)
public
ownerExists(msg.sender)
confirmed(transactionId, msg.sender)
notExecuted(transactionId)
{
confirmations[transactionId][msg.sender] = false;
Revocation(msg.sender, transactionId);
}
/// @dev Allows anyone to execute a confirmed transaction.
/// @param transactionId Transaction ID.
function executeTransaction(uint transactionId)
public
notExecuted(transactionId)
{
if (isConfirmed(transactionId)) {
Transaction tx = transactions[transactionId];
tx.executed = true;
if (tx.destination.call.value(tx.value)(tx.data))
Execution(transactionId);
else {
ExecutionFailure(transactionId);
tx.executed = false;
}
}
}
/// @dev Returns the confirmation status of a transaction.
/// @param transactionId Transaction ID.
/// @return Confirmation status.
function isConfirmed(uint transactionId)
public
constant
returns (bool)
{
uint count = 0;
for (uint i=0; i<owners.length; i++) {
if (confirmations[transactionId][owners[i]])
count += 1;
if (count == required)
return true;
}
}
/*
* Internal functions
*/
/// @dev Adds a new transaction to the transaction mapping, if transaction does not exist yet.
/// @param destination Transaction target address.
/// @param value Transaction ether value.
/// @param data Transaction data payload.
/// @return Returns transaction ID.
function addTransaction(address destination, uint value, bytes data)
internal
notNull(destination)
returns (uint transactionId)
{
transactionId = transactionCount;
transactions[transactionId] = Transaction({
destination: destination,
value: value,
data: data,
executed: false
});
transactionCount += 1;
Submission(transactionId);
}
/*
* Web3 call functions
*/
/// @dev Returns number of confirmations of a transaction.
/// @param transactionId Transaction ID.
/// @return Number of confirmations.
function getConfirmationCount(uint transactionId)
public
constant
returns (uint count)
{
for (uint i=0; i<owners.length; i++)
if (confirmations[transactionId][owners[i]])
count += 1;
}
/// @dev Returns total number of transactions after filers are applied.
/// @param pending Include pending transactions.
/// @param executed Include executed transactions.
/// @return Total number of transactions after filters are applied.
function getTransactionCount(bool pending, bool executed)
public
constant
returns (uint count)
{
for (uint i=0; i<transactionCount; i++)
if ( pending && !transactions[i].executed
|| executed && transactions[i].executed)
count += 1;
}
/// @dev Returns list of owners.
/// @return List of owner addresses.
function getOwners()
public
constant
returns (address[])
{
return owners;
}
/// @dev Returns array with owner addresses, which confirmed transaction.
/// @param transactionId Transaction ID.
/// @return Returns array of owner addresses.
function getConfirmations(uint transactionId)
public
constant
returns (address[] _confirmations)
{
address[] memory confirmationsTemp = new address[](owners.length);
uint count = 0;
uint i;
for (i=0; i<owners.length; i++)
if (confirmations[transactionId][owners[i]]) {
confirmationsTemp[count] = owners[i];
count += 1;
}
_confirmations = new address[](count);
for (i=0; i<count; i++)
_confirmations[i] = confirmationsTemp[i];
}
/// @dev Returns list of transaction IDs in defined range.
/// @param from Index start position of transaction array.
/// @param to Index end position of transaction array.
/// @param pending Include pending transactions.
/// @param executed Include executed transactions.
/// @return Returns array of transaction IDs.
function getTransactionIds(uint from, uint to, bool pending, bool executed)
public
constant
returns (uint[] _transactionIds)
{
uint[] memory transactionIdsTemp = new uint[](transactionCount);
uint count = 0;
uint i;
for (i=0; i<transactionCount; i++)
if ( pending && !transactions[i].executed
|| executed && transactions[i].executed)
{
transactionIdsTemp[count] = i;
count += 1;
}
_transactionIds = new uint[](to - from);
for (i=from; i<to; i++)
_transactionIds[i - from] = transactionIdsTemp[i];
}
/// @dev Create new coin.
function createCoin()
external
onlyWallet
{
require(flag == true);
CoinCreation(new Gifto());
flag = false;
}
} | /// @title Multisignature wallet - Allows multiple parties to agree on transactions before execution.
/// @author Stefan George - <[email protected]> | NatSpecSingleLine | changeRequirement | function changeRequirement(uint _required)
public
onlyWallet
validRequirement(owners.length, _required)
{
required = _required;
RequirementChange(_required);
}
| /// @dev Allows to change the number of required confirmations. Transaction has to be sent by wallet.
/// @param _required Number of required confirmations. | NatSpecSingleLine | v0.4.18+commit.9cf6e910 | bzzr://891e8485538f16f2fa5b9af11f8c795bc62d51fb6455063a6ee3652fa7680f20 | {
"func_code_index": [
5059,
5278
]
} | 3,538 |
|
MultiSigWallet | MultiSigWallet.sol | 0x615ed6779507f223d04722d43ccc0cd871964e2a | Solidity | MultiSigWallet | contract MultiSigWallet {
uint constant public MAX_OWNER_COUNT = 50;
event Confirmation(address indexed sender, uint indexed transactionId);
event Revocation(address indexed sender, uint indexed transactionId);
event Submission(uint indexed transactionId);
event Execution(uint indexed transactionId);
event ExecutionFailure(uint indexed transactionId);
event Deposit(address indexed sender, uint value);
event OwnerAddition(address indexed owner);
event OwnerRemoval(address indexed owner);
event RequirementChange(uint required);
event CoinCreation(address coin);
mapping (uint => Transaction) public transactions;
mapping (uint => mapping (address => bool)) public confirmations;
mapping (address => bool) public isOwner;
address[] public owners;
uint public required;
uint public transactionCount;
bool flag = true;
struct Transaction {
address destination;
uint value;
bytes data;
bool executed;
}
modifier onlyWallet() {
if (msg.sender != address(this))
revert();
_;
}
modifier ownerDoesNotExist(address owner) {
if (isOwner[owner])
revert();
_;
}
modifier ownerExists(address owner) {
if (!isOwner[owner])
revert();
_;
}
modifier transactionExists(uint transactionId) {
if (transactions[transactionId].destination == 0)
revert();
_;
}
modifier confirmed(uint transactionId, address owner) {
if (!confirmations[transactionId][owner])
revert();
_;
}
modifier notConfirmed(uint transactionId, address owner) {
if (confirmations[transactionId][owner])
revert();
_;
}
modifier notExecuted(uint transactionId) {
if (transactions[transactionId].executed)
revert();
_;
}
modifier notNull(address _address) {
if (_address == 0)
revert();
_;
}
modifier validRequirement(uint ownerCount, uint _required) {
if ( ownerCount > MAX_OWNER_COUNT
|| _required > ownerCount
|| _required == 0
|| ownerCount == 0)
revert();
_;
}
/// @dev Fallback function allows to deposit ether.
function()
payable
{
if (msg.value > 0)
Deposit(msg.sender, msg.value);
}
/*
* Public functions
*/
/// @dev Contract constructor sets initial owners and required number of confirmations.
/// @param _owners List of initial owners.
/// @param _required Number of required confirmations.
function MultiSigWallet(address[] _owners, uint _required)
public
validRequirement(_owners.length, _required)
{
for (uint i=0; i<_owners.length; i++) {
if (isOwner[_owners[i]] || _owners[i] == 0)
revert();
isOwner[_owners[i]] = true;
}
owners = _owners;
required = _required;
}
/// @dev Allows to add a new owner. Transaction has to be sent by wallet.
/// @param owner Address of new owner.
function addOwner(address owner)
public
onlyWallet
ownerDoesNotExist(owner)
notNull(owner)
validRequirement(owners.length + 1, required)
{
isOwner[owner] = true;
owners.push(owner);
OwnerAddition(owner);
}
/// @dev Allows to remove an owner. Transaction has to be sent by wallet.
/// @param owner Address of owner.
function removeOwner(address owner)
public
onlyWallet
ownerExists(owner)
{
isOwner[owner] = false;
for (uint i=0; i<owners.length - 1; i++)
if (owners[i] == owner) {
owners[i] = owners[owners.length - 1];
break;
}
owners.length -= 1;
if (required > owners.length)
changeRequirement(owners.length);
OwnerRemoval(owner);
}
/// @dev Allows to replace an owner with a new owner. Transaction has to be sent by wallet.
/// @param owner Address of owner to be replaced.
/// @param owner Address of new owner.
function replaceOwner(address owner, address newOwner)
public
onlyWallet
ownerExists(owner)
ownerDoesNotExist(newOwner)
{
for (uint i=0; i<owners.length; i++)
if (owners[i] == owner) {
owners[i] = newOwner;
break;
}
isOwner[owner] = false;
isOwner[newOwner] = true;
OwnerRemoval(owner);
OwnerAddition(newOwner);
}
/// @dev Allows to change the number of required confirmations. Transaction has to be sent by wallet.
/// @param _required Number of required confirmations.
function changeRequirement(uint _required)
public
onlyWallet
validRequirement(owners.length, _required)
{
required = _required;
RequirementChange(_required);
}
/// @dev Allows an owner to submit and confirm a transaction.
/// @param destination Transaction target address.
/// @param value Transaction ether value.
/// @param data Transaction data payload.
/// @return Returns transaction ID.
function submitTransaction(address destination, uint value, bytes data)
public
returns (uint transactionId)
{
transactionId = addTransaction(destination, value, data);
confirmTransaction(transactionId);
}
/// @dev Allows an owner to confirm a transaction.
/// @param transactionId Transaction ID.
function confirmTransaction(uint transactionId)
public
ownerExists(msg.sender)
transactionExists(transactionId)
notConfirmed(transactionId, msg.sender)
{
confirmations[transactionId][msg.sender] = true;
Confirmation(msg.sender, transactionId);
executeTransaction(transactionId);
}
/// @dev Allows an owner to revoke a confirmation for a transaction.
/// @param transactionId Transaction ID.
function revokeConfirmation(uint transactionId)
public
ownerExists(msg.sender)
confirmed(transactionId, msg.sender)
notExecuted(transactionId)
{
confirmations[transactionId][msg.sender] = false;
Revocation(msg.sender, transactionId);
}
/// @dev Allows anyone to execute a confirmed transaction.
/// @param transactionId Transaction ID.
function executeTransaction(uint transactionId)
public
notExecuted(transactionId)
{
if (isConfirmed(transactionId)) {
Transaction tx = transactions[transactionId];
tx.executed = true;
if (tx.destination.call.value(tx.value)(tx.data))
Execution(transactionId);
else {
ExecutionFailure(transactionId);
tx.executed = false;
}
}
}
/// @dev Returns the confirmation status of a transaction.
/// @param transactionId Transaction ID.
/// @return Confirmation status.
function isConfirmed(uint transactionId)
public
constant
returns (bool)
{
uint count = 0;
for (uint i=0; i<owners.length; i++) {
if (confirmations[transactionId][owners[i]])
count += 1;
if (count == required)
return true;
}
}
/*
* Internal functions
*/
/// @dev Adds a new transaction to the transaction mapping, if transaction does not exist yet.
/// @param destination Transaction target address.
/// @param value Transaction ether value.
/// @param data Transaction data payload.
/// @return Returns transaction ID.
function addTransaction(address destination, uint value, bytes data)
internal
notNull(destination)
returns (uint transactionId)
{
transactionId = transactionCount;
transactions[transactionId] = Transaction({
destination: destination,
value: value,
data: data,
executed: false
});
transactionCount += 1;
Submission(transactionId);
}
/*
* Web3 call functions
*/
/// @dev Returns number of confirmations of a transaction.
/// @param transactionId Transaction ID.
/// @return Number of confirmations.
function getConfirmationCount(uint transactionId)
public
constant
returns (uint count)
{
for (uint i=0; i<owners.length; i++)
if (confirmations[transactionId][owners[i]])
count += 1;
}
/// @dev Returns total number of transactions after filers are applied.
/// @param pending Include pending transactions.
/// @param executed Include executed transactions.
/// @return Total number of transactions after filters are applied.
function getTransactionCount(bool pending, bool executed)
public
constant
returns (uint count)
{
for (uint i=0; i<transactionCount; i++)
if ( pending && !transactions[i].executed
|| executed && transactions[i].executed)
count += 1;
}
/// @dev Returns list of owners.
/// @return List of owner addresses.
function getOwners()
public
constant
returns (address[])
{
return owners;
}
/// @dev Returns array with owner addresses, which confirmed transaction.
/// @param transactionId Transaction ID.
/// @return Returns array of owner addresses.
function getConfirmations(uint transactionId)
public
constant
returns (address[] _confirmations)
{
address[] memory confirmationsTemp = new address[](owners.length);
uint count = 0;
uint i;
for (i=0; i<owners.length; i++)
if (confirmations[transactionId][owners[i]]) {
confirmationsTemp[count] = owners[i];
count += 1;
}
_confirmations = new address[](count);
for (i=0; i<count; i++)
_confirmations[i] = confirmationsTemp[i];
}
/// @dev Returns list of transaction IDs in defined range.
/// @param from Index start position of transaction array.
/// @param to Index end position of transaction array.
/// @param pending Include pending transactions.
/// @param executed Include executed transactions.
/// @return Returns array of transaction IDs.
function getTransactionIds(uint from, uint to, bool pending, bool executed)
public
constant
returns (uint[] _transactionIds)
{
uint[] memory transactionIdsTemp = new uint[](transactionCount);
uint count = 0;
uint i;
for (i=0; i<transactionCount; i++)
if ( pending && !transactions[i].executed
|| executed && transactions[i].executed)
{
transactionIdsTemp[count] = i;
count += 1;
}
_transactionIds = new uint[](to - from);
for (i=from; i<to; i++)
_transactionIds[i - from] = transactionIdsTemp[i];
}
/// @dev Create new coin.
function createCoin()
external
onlyWallet
{
require(flag == true);
CoinCreation(new Gifto());
flag = false;
}
} | /// @title Multisignature wallet - Allows multiple parties to agree on transactions before execution.
/// @author Stefan George - <[email protected]> | NatSpecSingleLine | submitTransaction | function submitTransaction(address destination, uint value, bytes data)
public
returns (uint transactionId)
{
transactionId = addTransaction(destination, value, data);
confirmTransaction(transactionId);
}
| /// @dev Allows an owner to submit and confirm a transaction.
/// @param destination Transaction target address.
/// @param value Transaction ether value.
/// @param data Transaction data payload.
/// @return Returns transaction ID. | NatSpecSingleLine | v0.4.18+commit.9cf6e910 | bzzr://891e8485538f16f2fa5b9af11f8c795bc62d51fb6455063a6ee3652fa7680f20 | {
"func_code_index": [
5539,
5794
]
} | 3,539 |
|
MultiSigWallet | MultiSigWallet.sol | 0x615ed6779507f223d04722d43ccc0cd871964e2a | Solidity | MultiSigWallet | contract MultiSigWallet {
uint constant public MAX_OWNER_COUNT = 50;
event Confirmation(address indexed sender, uint indexed transactionId);
event Revocation(address indexed sender, uint indexed transactionId);
event Submission(uint indexed transactionId);
event Execution(uint indexed transactionId);
event ExecutionFailure(uint indexed transactionId);
event Deposit(address indexed sender, uint value);
event OwnerAddition(address indexed owner);
event OwnerRemoval(address indexed owner);
event RequirementChange(uint required);
event CoinCreation(address coin);
mapping (uint => Transaction) public transactions;
mapping (uint => mapping (address => bool)) public confirmations;
mapping (address => bool) public isOwner;
address[] public owners;
uint public required;
uint public transactionCount;
bool flag = true;
struct Transaction {
address destination;
uint value;
bytes data;
bool executed;
}
modifier onlyWallet() {
if (msg.sender != address(this))
revert();
_;
}
modifier ownerDoesNotExist(address owner) {
if (isOwner[owner])
revert();
_;
}
modifier ownerExists(address owner) {
if (!isOwner[owner])
revert();
_;
}
modifier transactionExists(uint transactionId) {
if (transactions[transactionId].destination == 0)
revert();
_;
}
modifier confirmed(uint transactionId, address owner) {
if (!confirmations[transactionId][owner])
revert();
_;
}
modifier notConfirmed(uint transactionId, address owner) {
if (confirmations[transactionId][owner])
revert();
_;
}
modifier notExecuted(uint transactionId) {
if (transactions[transactionId].executed)
revert();
_;
}
modifier notNull(address _address) {
if (_address == 0)
revert();
_;
}
modifier validRequirement(uint ownerCount, uint _required) {
if ( ownerCount > MAX_OWNER_COUNT
|| _required > ownerCount
|| _required == 0
|| ownerCount == 0)
revert();
_;
}
/// @dev Fallback function allows to deposit ether.
function()
payable
{
if (msg.value > 0)
Deposit(msg.sender, msg.value);
}
/*
* Public functions
*/
/// @dev Contract constructor sets initial owners and required number of confirmations.
/// @param _owners List of initial owners.
/// @param _required Number of required confirmations.
function MultiSigWallet(address[] _owners, uint _required)
public
validRequirement(_owners.length, _required)
{
for (uint i=0; i<_owners.length; i++) {
if (isOwner[_owners[i]] || _owners[i] == 0)
revert();
isOwner[_owners[i]] = true;
}
owners = _owners;
required = _required;
}
/// @dev Allows to add a new owner. Transaction has to be sent by wallet.
/// @param owner Address of new owner.
function addOwner(address owner)
public
onlyWallet
ownerDoesNotExist(owner)
notNull(owner)
validRequirement(owners.length + 1, required)
{
isOwner[owner] = true;
owners.push(owner);
OwnerAddition(owner);
}
/// @dev Allows to remove an owner. Transaction has to be sent by wallet.
/// @param owner Address of owner.
function removeOwner(address owner)
public
onlyWallet
ownerExists(owner)
{
isOwner[owner] = false;
for (uint i=0; i<owners.length - 1; i++)
if (owners[i] == owner) {
owners[i] = owners[owners.length - 1];
break;
}
owners.length -= 1;
if (required > owners.length)
changeRequirement(owners.length);
OwnerRemoval(owner);
}
/// @dev Allows to replace an owner with a new owner. Transaction has to be sent by wallet.
/// @param owner Address of owner to be replaced.
/// @param owner Address of new owner.
function replaceOwner(address owner, address newOwner)
public
onlyWallet
ownerExists(owner)
ownerDoesNotExist(newOwner)
{
for (uint i=0; i<owners.length; i++)
if (owners[i] == owner) {
owners[i] = newOwner;
break;
}
isOwner[owner] = false;
isOwner[newOwner] = true;
OwnerRemoval(owner);
OwnerAddition(newOwner);
}
/// @dev Allows to change the number of required confirmations. Transaction has to be sent by wallet.
/// @param _required Number of required confirmations.
function changeRequirement(uint _required)
public
onlyWallet
validRequirement(owners.length, _required)
{
required = _required;
RequirementChange(_required);
}
/// @dev Allows an owner to submit and confirm a transaction.
/// @param destination Transaction target address.
/// @param value Transaction ether value.
/// @param data Transaction data payload.
/// @return Returns transaction ID.
function submitTransaction(address destination, uint value, bytes data)
public
returns (uint transactionId)
{
transactionId = addTransaction(destination, value, data);
confirmTransaction(transactionId);
}
/// @dev Allows an owner to confirm a transaction.
/// @param transactionId Transaction ID.
function confirmTransaction(uint transactionId)
public
ownerExists(msg.sender)
transactionExists(transactionId)
notConfirmed(transactionId, msg.sender)
{
confirmations[transactionId][msg.sender] = true;
Confirmation(msg.sender, transactionId);
executeTransaction(transactionId);
}
/// @dev Allows an owner to revoke a confirmation for a transaction.
/// @param transactionId Transaction ID.
function revokeConfirmation(uint transactionId)
public
ownerExists(msg.sender)
confirmed(transactionId, msg.sender)
notExecuted(transactionId)
{
confirmations[transactionId][msg.sender] = false;
Revocation(msg.sender, transactionId);
}
/// @dev Allows anyone to execute a confirmed transaction.
/// @param transactionId Transaction ID.
function executeTransaction(uint transactionId)
public
notExecuted(transactionId)
{
if (isConfirmed(transactionId)) {
Transaction tx = transactions[transactionId];
tx.executed = true;
if (tx.destination.call.value(tx.value)(tx.data))
Execution(transactionId);
else {
ExecutionFailure(transactionId);
tx.executed = false;
}
}
}
/// @dev Returns the confirmation status of a transaction.
/// @param transactionId Transaction ID.
/// @return Confirmation status.
function isConfirmed(uint transactionId)
public
constant
returns (bool)
{
uint count = 0;
for (uint i=0; i<owners.length; i++) {
if (confirmations[transactionId][owners[i]])
count += 1;
if (count == required)
return true;
}
}
/*
* Internal functions
*/
/// @dev Adds a new transaction to the transaction mapping, if transaction does not exist yet.
/// @param destination Transaction target address.
/// @param value Transaction ether value.
/// @param data Transaction data payload.
/// @return Returns transaction ID.
function addTransaction(address destination, uint value, bytes data)
internal
notNull(destination)
returns (uint transactionId)
{
transactionId = transactionCount;
transactions[transactionId] = Transaction({
destination: destination,
value: value,
data: data,
executed: false
});
transactionCount += 1;
Submission(transactionId);
}
/*
* Web3 call functions
*/
/// @dev Returns number of confirmations of a transaction.
/// @param transactionId Transaction ID.
/// @return Number of confirmations.
function getConfirmationCount(uint transactionId)
public
constant
returns (uint count)
{
for (uint i=0; i<owners.length; i++)
if (confirmations[transactionId][owners[i]])
count += 1;
}
/// @dev Returns total number of transactions after filers are applied.
/// @param pending Include pending transactions.
/// @param executed Include executed transactions.
/// @return Total number of transactions after filters are applied.
function getTransactionCount(bool pending, bool executed)
public
constant
returns (uint count)
{
for (uint i=0; i<transactionCount; i++)
if ( pending && !transactions[i].executed
|| executed && transactions[i].executed)
count += 1;
}
/// @dev Returns list of owners.
/// @return List of owner addresses.
function getOwners()
public
constant
returns (address[])
{
return owners;
}
/// @dev Returns array with owner addresses, which confirmed transaction.
/// @param transactionId Transaction ID.
/// @return Returns array of owner addresses.
function getConfirmations(uint transactionId)
public
constant
returns (address[] _confirmations)
{
address[] memory confirmationsTemp = new address[](owners.length);
uint count = 0;
uint i;
for (i=0; i<owners.length; i++)
if (confirmations[transactionId][owners[i]]) {
confirmationsTemp[count] = owners[i];
count += 1;
}
_confirmations = new address[](count);
for (i=0; i<count; i++)
_confirmations[i] = confirmationsTemp[i];
}
/// @dev Returns list of transaction IDs in defined range.
/// @param from Index start position of transaction array.
/// @param to Index end position of transaction array.
/// @param pending Include pending transactions.
/// @param executed Include executed transactions.
/// @return Returns array of transaction IDs.
function getTransactionIds(uint from, uint to, bool pending, bool executed)
public
constant
returns (uint[] _transactionIds)
{
uint[] memory transactionIdsTemp = new uint[](transactionCount);
uint count = 0;
uint i;
for (i=0; i<transactionCount; i++)
if ( pending && !transactions[i].executed
|| executed && transactions[i].executed)
{
transactionIdsTemp[count] = i;
count += 1;
}
_transactionIds = new uint[](to - from);
for (i=from; i<to; i++)
_transactionIds[i - from] = transactionIdsTemp[i];
}
/// @dev Create new coin.
function createCoin()
external
onlyWallet
{
require(flag == true);
CoinCreation(new Gifto());
flag = false;
}
} | /// @title Multisignature wallet - Allows multiple parties to agree on transactions before execution.
/// @author Stefan George - <[email protected]> | NatSpecSingleLine | confirmTransaction | function confirmTransaction(uint transactionId)
public
ownerExists(msg.sender)
transactionExists(transactionId)
notConfirmed(transactionId, msg.sender)
{
confirmations[transactionId][msg.sender] = true;
Confirmation(msg.sender, transactionId);
executeTransaction(transactionId);
}
| /// @dev Allows an owner to confirm a transaction.
/// @param transactionId Transaction ID. | NatSpecSingleLine | v0.4.18+commit.9cf6e910 | bzzr://891e8485538f16f2fa5b9af11f8c795bc62d51fb6455063a6ee3652fa7680f20 | {
"func_code_index": [
5899,
6257
]
} | 3,540 |
|
MultiSigWallet | MultiSigWallet.sol | 0x615ed6779507f223d04722d43ccc0cd871964e2a | Solidity | MultiSigWallet | contract MultiSigWallet {
uint constant public MAX_OWNER_COUNT = 50;
event Confirmation(address indexed sender, uint indexed transactionId);
event Revocation(address indexed sender, uint indexed transactionId);
event Submission(uint indexed transactionId);
event Execution(uint indexed transactionId);
event ExecutionFailure(uint indexed transactionId);
event Deposit(address indexed sender, uint value);
event OwnerAddition(address indexed owner);
event OwnerRemoval(address indexed owner);
event RequirementChange(uint required);
event CoinCreation(address coin);
mapping (uint => Transaction) public transactions;
mapping (uint => mapping (address => bool)) public confirmations;
mapping (address => bool) public isOwner;
address[] public owners;
uint public required;
uint public transactionCount;
bool flag = true;
struct Transaction {
address destination;
uint value;
bytes data;
bool executed;
}
modifier onlyWallet() {
if (msg.sender != address(this))
revert();
_;
}
modifier ownerDoesNotExist(address owner) {
if (isOwner[owner])
revert();
_;
}
modifier ownerExists(address owner) {
if (!isOwner[owner])
revert();
_;
}
modifier transactionExists(uint transactionId) {
if (transactions[transactionId].destination == 0)
revert();
_;
}
modifier confirmed(uint transactionId, address owner) {
if (!confirmations[transactionId][owner])
revert();
_;
}
modifier notConfirmed(uint transactionId, address owner) {
if (confirmations[transactionId][owner])
revert();
_;
}
modifier notExecuted(uint transactionId) {
if (transactions[transactionId].executed)
revert();
_;
}
modifier notNull(address _address) {
if (_address == 0)
revert();
_;
}
modifier validRequirement(uint ownerCount, uint _required) {
if ( ownerCount > MAX_OWNER_COUNT
|| _required > ownerCount
|| _required == 0
|| ownerCount == 0)
revert();
_;
}
/// @dev Fallback function allows to deposit ether.
function()
payable
{
if (msg.value > 0)
Deposit(msg.sender, msg.value);
}
/*
* Public functions
*/
/// @dev Contract constructor sets initial owners and required number of confirmations.
/// @param _owners List of initial owners.
/// @param _required Number of required confirmations.
function MultiSigWallet(address[] _owners, uint _required)
public
validRequirement(_owners.length, _required)
{
for (uint i=0; i<_owners.length; i++) {
if (isOwner[_owners[i]] || _owners[i] == 0)
revert();
isOwner[_owners[i]] = true;
}
owners = _owners;
required = _required;
}
/// @dev Allows to add a new owner. Transaction has to be sent by wallet.
/// @param owner Address of new owner.
function addOwner(address owner)
public
onlyWallet
ownerDoesNotExist(owner)
notNull(owner)
validRequirement(owners.length + 1, required)
{
isOwner[owner] = true;
owners.push(owner);
OwnerAddition(owner);
}
/// @dev Allows to remove an owner. Transaction has to be sent by wallet.
/// @param owner Address of owner.
function removeOwner(address owner)
public
onlyWallet
ownerExists(owner)
{
isOwner[owner] = false;
for (uint i=0; i<owners.length - 1; i++)
if (owners[i] == owner) {
owners[i] = owners[owners.length - 1];
break;
}
owners.length -= 1;
if (required > owners.length)
changeRequirement(owners.length);
OwnerRemoval(owner);
}
/// @dev Allows to replace an owner with a new owner. Transaction has to be sent by wallet.
/// @param owner Address of owner to be replaced.
/// @param owner Address of new owner.
function replaceOwner(address owner, address newOwner)
public
onlyWallet
ownerExists(owner)
ownerDoesNotExist(newOwner)
{
for (uint i=0; i<owners.length; i++)
if (owners[i] == owner) {
owners[i] = newOwner;
break;
}
isOwner[owner] = false;
isOwner[newOwner] = true;
OwnerRemoval(owner);
OwnerAddition(newOwner);
}
/// @dev Allows to change the number of required confirmations. Transaction has to be sent by wallet.
/// @param _required Number of required confirmations.
function changeRequirement(uint _required)
public
onlyWallet
validRequirement(owners.length, _required)
{
required = _required;
RequirementChange(_required);
}
/// @dev Allows an owner to submit and confirm a transaction.
/// @param destination Transaction target address.
/// @param value Transaction ether value.
/// @param data Transaction data payload.
/// @return Returns transaction ID.
function submitTransaction(address destination, uint value, bytes data)
public
returns (uint transactionId)
{
transactionId = addTransaction(destination, value, data);
confirmTransaction(transactionId);
}
/// @dev Allows an owner to confirm a transaction.
/// @param transactionId Transaction ID.
function confirmTransaction(uint transactionId)
public
ownerExists(msg.sender)
transactionExists(transactionId)
notConfirmed(transactionId, msg.sender)
{
confirmations[transactionId][msg.sender] = true;
Confirmation(msg.sender, transactionId);
executeTransaction(transactionId);
}
/// @dev Allows an owner to revoke a confirmation for a transaction.
/// @param transactionId Transaction ID.
function revokeConfirmation(uint transactionId)
public
ownerExists(msg.sender)
confirmed(transactionId, msg.sender)
notExecuted(transactionId)
{
confirmations[transactionId][msg.sender] = false;
Revocation(msg.sender, transactionId);
}
/// @dev Allows anyone to execute a confirmed transaction.
/// @param transactionId Transaction ID.
function executeTransaction(uint transactionId)
public
notExecuted(transactionId)
{
if (isConfirmed(transactionId)) {
Transaction tx = transactions[transactionId];
tx.executed = true;
if (tx.destination.call.value(tx.value)(tx.data))
Execution(transactionId);
else {
ExecutionFailure(transactionId);
tx.executed = false;
}
}
}
/// @dev Returns the confirmation status of a transaction.
/// @param transactionId Transaction ID.
/// @return Confirmation status.
function isConfirmed(uint transactionId)
public
constant
returns (bool)
{
uint count = 0;
for (uint i=0; i<owners.length; i++) {
if (confirmations[transactionId][owners[i]])
count += 1;
if (count == required)
return true;
}
}
/*
* Internal functions
*/
/// @dev Adds a new transaction to the transaction mapping, if transaction does not exist yet.
/// @param destination Transaction target address.
/// @param value Transaction ether value.
/// @param data Transaction data payload.
/// @return Returns transaction ID.
function addTransaction(address destination, uint value, bytes data)
internal
notNull(destination)
returns (uint transactionId)
{
transactionId = transactionCount;
transactions[transactionId] = Transaction({
destination: destination,
value: value,
data: data,
executed: false
});
transactionCount += 1;
Submission(transactionId);
}
/*
* Web3 call functions
*/
/// @dev Returns number of confirmations of a transaction.
/// @param transactionId Transaction ID.
/// @return Number of confirmations.
function getConfirmationCount(uint transactionId)
public
constant
returns (uint count)
{
for (uint i=0; i<owners.length; i++)
if (confirmations[transactionId][owners[i]])
count += 1;
}
/// @dev Returns total number of transactions after filers are applied.
/// @param pending Include pending transactions.
/// @param executed Include executed transactions.
/// @return Total number of transactions after filters are applied.
function getTransactionCount(bool pending, bool executed)
public
constant
returns (uint count)
{
for (uint i=0; i<transactionCount; i++)
if ( pending && !transactions[i].executed
|| executed && transactions[i].executed)
count += 1;
}
/// @dev Returns list of owners.
/// @return List of owner addresses.
function getOwners()
public
constant
returns (address[])
{
return owners;
}
/// @dev Returns array with owner addresses, which confirmed transaction.
/// @param transactionId Transaction ID.
/// @return Returns array of owner addresses.
function getConfirmations(uint transactionId)
public
constant
returns (address[] _confirmations)
{
address[] memory confirmationsTemp = new address[](owners.length);
uint count = 0;
uint i;
for (i=0; i<owners.length; i++)
if (confirmations[transactionId][owners[i]]) {
confirmationsTemp[count] = owners[i];
count += 1;
}
_confirmations = new address[](count);
for (i=0; i<count; i++)
_confirmations[i] = confirmationsTemp[i];
}
/// @dev Returns list of transaction IDs in defined range.
/// @param from Index start position of transaction array.
/// @param to Index end position of transaction array.
/// @param pending Include pending transactions.
/// @param executed Include executed transactions.
/// @return Returns array of transaction IDs.
function getTransactionIds(uint from, uint to, bool pending, bool executed)
public
constant
returns (uint[] _transactionIds)
{
uint[] memory transactionIdsTemp = new uint[](transactionCount);
uint count = 0;
uint i;
for (i=0; i<transactionCount; i++)
if ( pending && !transactions[i].executed
|| executed && transactions[i].executed)
{
transactionIdsTemp[count] = i;
count += 1;
}
_transactionIds = new uint[](to - from);
for (i=from; i<to; i++)
_transactionIds[i - from] = transactionIdsTemp[i];
}
/// @dev Create new coin.
function createCoin()
external
onlyWallet
{
require(flag == true);
CoinCreation(new Gifto());
flag = false;
}
} | /// @title Multisignature wallet - Allows multiple parties to agree on transactions before execution.
/// @author Stefan George - <[email protected]> | NatSpecSingleLine | revokeConfirmation | function revokeConfirmation(uint transactionId)
public
ownerExists(msg.sender)
confirmed(transactionId, msg.sender)
notExecuted(transactionId)
{
confirmations[transactionId][msg.sender] = false;
Revocation(msg.sender, transactionId);
}
| /// @dev Allows an owner to revoke a confirmation for a transaction.
/// @param transactionId Transaction ID. | NatSpecSingleLine | v0.4.18+commit.9cf6e910 | bzzr://891e8485538f16f2fa5b9af11f8c795bc62d51fb6455063a6ee3652fa7680f20 | {
"func_code_index": [
6380,
6684
]
} | 3,541 |
|
MultiSigWallet | MultiSigWallet.sol | 0x615ed6779507f223d04722d43ccc0cd871964e2a | Solidity | MultiSigWallet | contract MultiSigWallet {
uint constant public MAX_OWNER_COUNT = 50;
event Confirmation(address indexed sender, uint indexed transactionId);
event Revocation(address indexed sender, uint indexed transactionId);
event Submission(uint indexed transactionId);
event Execution(uint indexed transactionId);
event ExecutionFailure(uint indexed transactionId);
event Deposit(address indexed sender, uint value);
event OwnerAddition(address indexed owner);
event OwnerRemoval(address indexed owner);
event RequirementChange(uint required);
event CoinCreation(address coin);
mapping (uint => Transaction) public transactions;
mapping (uint => mapping (address => bool)) public confirmations;
mapping (address => bool) public isOwner;
address[] public owners;
uint public required;
uint public transactionCount;
bool flag = true;
struct Transaction {
address destination;
uint value;
bytes data;
bool executed;
}
modifier onlyWallet() {
if (msg.sender != address(this))
revert();
_;
}
modifier ownerDoesNotExist(address owner) {
if (isOwner[owner])
revert();
_;
}
modifier ownerExists(address owner) {
if (!isOwner[owner])
revert();
_;
}
modifier transactionExists(uint transactionId) {
if (transactions[transactionId].destination == 0)
revert();
_;
}
modifier confirmed(uint transactionId, address owner) {
if (!confirmations[transactionId][owner])
revert();
_;
}
modifier notConfirmed(uint transactionId, address owner) {
if (confirmations[transactionId][owner])
revert();
_;
}
modifier notExecuted(uint transactionId) {
if (transactions[transactionId].executed)
revert();
_;
}
modifier notNull(address _address) {
if (_address == 0)
revert();
_;
}
modifier validRequirement(uint ownerCount, uint _required) {
if ( ownerCount > MAX_OWNER_COUNT
|| _required > ownerCount
|| _required == 0
|| ownerCount == 0)
revert();
_;
}
/// @dev Fallback function allows to deposit ether.
function()
payable
{
if (msg.value > 0)
Deposit(msg.sender, msg.value);
}
/*
* Public functions
*/
/// @dev Contract constructor sets initial owners and required number of confirmations.
/// @param _owners List of initial owners.
/// @param _required Number of required confirmations.
function MultiSigWallet(address[] _owners, uint _required)
public
validRequirement(_owners.length, _required)
{
for (uint i=0; i<_owners.length; i++) {
if (isOwner[_owners[i]] || _owners[i] == 0)
revert();
isOwner[_owners[i]] = true;
}
owners = _owners;
required = _required;
}
/// @dev Allows to add a new owner. Transaction has to be sent by wallet.
/// @param owner Address of new owner.
function addOwner(address owner)
public
onlyWallet
ownerDoesNotExist(owner)
notNull(owner)
validRequirement(owners.length + 1, required)
{
isOwner[owner] = true;
owners.push(owner);
OwnerAddition(owner);
}
/// @dev Allows to remove an owner. Transaction has to be sent by wallet.
/// @param owner Address of owner.
function removeOwner(address owner)
public
onlyWallet
ownerExists(owner)
{
isOwner[owner] = false;
for (uint i=0; i<owners.length - 1; i++)
if (owners[i] == owner) {
owners[i] = owners[owners.length - 1];
break;
}
owners.length -= 1;
if (required > owners.length)
changeRequirement(owners.length);
OwnerRemoval(owner);
}
/// @dev Allows to replace an owner with a new owner. Transaction has to be sent by wallet.
/// @param owner Address of owner to be replaced.
/// @param owner Address of new owner.
function replaceOwner(address owner, address newOwner)
public
onlyWallet
ownerExists(owner)
ownerDoesNotExist(newOwner)
{
for (uint i=0; i<owners.length; i++)
if (owners[i] == owner) {
owners[i] = newOwner;
break;
}
isOwner[owner] = false;
isOwner[newOwner] = true;
OwnerRemoval(owner);
OwnerAddition(newOwner);
}
/// @dev Allows to change the number of required confirmations. Transaction has to be sent by wallet.
/// @param _required Number of required confirmations.
function changeRequirement(uint _required)
public
onlyWallet
validRequirement(owners.length, _required)
{
required = _required;
RequirementChange(_required);
}
/// @dev Allows an owner to submit and confirm a transaction.
/// @param destination Transaction target address.
/// @param value Transaction ether value.
/// @param data Transaction data payload.
/// @return Returns transaction ID.
function submitTransaction(address destination, uint value, bytes data)
public
returns (uint transactionId)
{
transactionId = addTransaction(destination, value, data);
confirmTransaction(transactionId);
}
/// @dev Allows an owner to confirm a transaction.
/// @param transactionId Transaction ID.
function confirmTransaction(uint transactionId)
public
ownerExists(msg.sender)
transactionExists(transactionId)
notConfirmed(transactionId, msg.sender)
{
confirmations[transactionId][msg.sender] = true;
Confirmation(msg.sender, transactionId);
executeTransaction(transactionId);
}
/// @dev Allows an owner to revoke a confirmation for a transaction.
/// @param transactionId Transaction ID.
function revokeConfirmation(uint transactionId)
public
ownerExists(msg.sender)
confirmed(transactionId, msg.sender)
notExecuted(transactionId)
{
confirmations[transactionId][msg.sender] = false;
Revocation(msg.sender, transactionId);
}
/// @dev Allows anyone to execute a confirmed transaction.
/// @param transactionId Transaction ID.
function executeTransaction(uint transactionId)
public
notExecuted(transactionId)
{
if (isConfirmed(transactionId)) {
Transaction tx = transactions[transactionId];
tx.executed = true;
if (tx.destination.call.value(tx.value)(tx.data))
Execution(transactionId);
else {
ExecutionFailure(transactionId);
tx.executed = false;
}
}
}
/// @dev Returns the confirmation status of a transaction.
/// @param transactionId Transaction ID.
/// @return Confirmation status.
function isConfirmed(uint transactionId)
public
constant
returns (bool)
{
uint count = 0;
for (uint i=0; i<owners.length; i++) {
if (confirmations[transactionId][owners[i]])
count += 1;
if (count == required)
return true;
}
}
/*
* Internal functions
*/
/// @dev Adds a new transaction to the transaction mapping, if transaction does not exist yet.
/// @param destination Transaction target address.
/// @param value Transaction ether value.
/// @param data Transaction data payload.
/// @return Returns transaction ID.
function addTransaction(address destination, uint value, bytes data)
internal
notNull(destination)
returns (uint transactionId)
{
transactionId = transactionCount;
transactions[transactionId] = Transaction({
destination: destination,
value: value,
data: data,
executed: false
});
transactionCount += 1;
Submission(transactionId);
}
/*
* Web3 call functions
*/
/// @dev Returns number of confirmations of a transaction.
/// @param transactionId Transaction ID.
/// @return Number of confirmations.
function getConfirmationCount(uint transactionId)
public
constant
returns (uint count)
{
for (uint i=0; i<owners.length; i++)
if (confirmations[transactionId][owners[i]])
count += 1;
}
/// @dev Returns total number of transactions after filers are applied.
/// @param pending Include pending transactions.
/// @param executed Include executed transactions.
/// @return Total number of transactions after filters are applied.
function getTransactionCount(bool pending, bool executed)
public
constant
returns (uint count)
{
for (uint i=0; i<transactionCount; i++)
if ( pending && !transactions[i].executed
|| executed && transactions[i].executed)
count += 1;
}
/// @dev Returns list of owners.
/// @return List of owner addresses.
function getOwners()
public
constant
returns (address[])
{
return owners;
}
/// @dev Returns array with owner addresses, which confirmed transaction.
/// @param transactionId Transaction ID.
/// @return Returns array of owner addresses.
function getConfirmations(uint transactionId)
public
constant
returns (address[] _confirmations)
{
address[] memory confirmationsTemp = new address[](owners.length);
uint count = 0;
uint i;
for (i=0; i<owners.length; i++)
if (confirmations[transactionId][owners[i]]) {
confirmationsTemp[count] = owners[i];
count += 1;
}
_confirmations = new address[](count);
for (i=0; i<count; i++)
_confirmations[i] = confirmationsTemp[i];
}
/// @dev Returns list of transaction IDs in defined range.
/// @param from Index start position of transaction array.
/// @param to Index end position of transaction array.
/// @param pending Include pending transactions.
/// @param executed Include executed transactions.
/// @return Returns array of transaction IDs.
function getTransactionIds(uint from, uint to, bool pending, bool executed)
public
constant
returns (uint[] _transactionIds)
{
uint[] memory transactionIdsTemp = new uint[](transactionCount);
uint count = 0;
uint i;
for (i=0; i<transactionCount; i++)
if ( pending && !transactions[i].executed
|| executed && transactions[i].executed)
{
transactionIdsTemp[count] = i;
count += 1;
}
_transactionIds = new uint[](to - from);
for (i=from; i<to; i++)
_transactionIds[i - from] = transactionIdsTemp[i];
}
/// @dev Create new coin.
function createCoin()
external
onlyWallet
{
require(flag == true);
CoinCreation(new Gifto());
flag = false;
}
} | /// @title Multisignature wallet - Allows multiple parties to agree on transactions before execution.
/// @author Stefan George - <[email protected]> | NatSpecSingleLine | executeTransaction | function executeTransaction(uint transactionId)
public
notExecuted(transactionId)
{
if (isConfirmed(transactionId)) {
Transaction tx = transactions[transactionId];
tx.executed = true;
if (tx.destination.call.value(tx.value)(tx.data))
Execution(transactionId);
else {
ExecutionFailure(transactionId);
tx.executed = false;
}
}
}
| /// @dev Allows anyone to execute a confirmed transaction.
/// @param transactionId Transaction ID. | NatSpecSingleLine | v0.4.18+commit.9cf6e910 | bzzr://891e8485538f16f2fa5b9af11f8c795bc62d51fb6455063a6ee3652fa7680f20 | {
"func_code_index": [
6797,
7290
]
} | 3,542 |
|
MultiSigWallet | MultiSigWallet.sol | 0x615ed6779507f223d04722d43ccc0cd871964e2a | Solidity | MultiSigWallet | contract MultiSigWallet {
uint constant public MAX_OWNER_COUNT = 50;
event Confirmation(address indexed sender, uint indexed transactionId);
event Revocation(address indexed sender, uint indexed transactionId);
event Submission(uint indexed transactionId);
event Execution(uint indexed transactionId);
event ExecutionFailure(uint indexed transactionId);
event Deposit(address indexed sender, uint value);
event OwnerAddition(address indexed owner);
event OwnerRemoval(address indexed owner);
event RequirementChange(uint required);
event CoinCreation(address coin);
mapping (uint => Transaction) public transactions;
mapping (uint => mapping (address => bool)) public confirmations;
mapping (address => bool) public isOwner;
address[] public owners;
uint public required;
uint public transactionCount;
bool flag = true;
struct Transaction {
address destination;
uint value;
bytes data;
bool executed;
}
modifier onlyWallet() {
if (msg.sender != address(this))
revert();
_;
}
modifier ownerDoesNotExist(address owner) {
if (isOwner[owner])
revert();
_;
}
modifier ownerExists(address owner) {
if (!isOwner[owner])
revert();
_;
}
modifier transactionExists(uint transactionId) {
if (transactions[transactionId].destination == 0)
revert();
_;
}
modifier confirmed(uint transactionId, address owner) {
if (!confirmations[transactionId][owner])
revert();
_;
}
modifier notConfirmed(uint transactionId, address owner) {
if (confirmations[transactionId][owner])
revert();
_;
}
modifier notExecuted(uint transactionId) {
if (transactions[transactionId].executed)
revert();
_;
}
modifier notNull(address _address) {
if (_address == 0)
revert();
_;
}
modifier validRequirement(uint ownerCount, uint _required) {
if ( ownerCount > MAX_OWNER_COUNT
|| _required > ownerCount
|| _required == 0
|| ownerCount == 0)
revert();
_;
}
/// @dev Fallback function allows to deposit ether.
function()
payable
{
if (msg.value > 0)
Deposit(msg.sender, msg.value);
}
/*
* Public functions
*/
/// @dev Contract constructor sets initial owners and required number of confirmations.
/// @param _owners List of initial owners.
/// @param _required Number of required confirmations.
function MultiSigWallet(address[] _owners, uint _required)
public
validRequirement(_owners.length, _required)
{
for (uint i=0; i<_owners.length; i++) {
if (isOwner[_owners[i]] || _owners[i] == 0)
revert();
isOwner[_owners[i]] = true;
}
owners = _owners;
required = _required;
}
/// @dev Allows to add a new owner. Transaction has to be sent by wallet.
/// @param owner Address of new owner.
function addOwner(address owner)
public
onlyWallet
ownerDoesNotExist(owner)
notNull(owner)
validRequirement(owners.length + 1, required)
{
isOwner[owner] = true;
owners.push(owner);
OwnerAddition(owner);
}
/// @dev Allows to remove an owner. Transaction has to be sent by wallet.
/// @param owner Address of owner.
function removeOwner(address owner)
public
onlyWallet
ownerExists(owner)
{
isOwner[owner] = false;
for (uint i=0; i<owners.length - 1; i++)
if (owners[i] == owner) {
owners[i] = owners[owners.length - 1];
break;
}
owners.length -= 1;
if (required > owners.length)
changeRequirement(owners.length);
OwnerRemoval(owner);
}
/// @dev Allows to replace an owner with a new owner. Transaction has to be sent by wallet.
/// @param owner Address of owner to be replaced.
/// @param owner Address of new owner.
function replaceOwner(address owner, address newOwner)
public
onlyWallet
ownerExists(owner)
ownerDoesNotExist(newOwner)
{
for (uint i=0; i<owners.length; i++)
if (owners[i] == owner) {
owners[i] = newOwner;
break;
}
isOwner[owner] = false;
isOwner[newOwner] = true;
OwnerRemoval(owner);
OwnerAddition(newOwner);
}
/// @dev Allows to change the number of required confirmations. Transaction has to be sent by wallet.
/// @param _required Number of required confirmations.
function changeRequirement(uint _required)
public
onlyWallet
validRequirement(owners.length, _required)
{
required = _required;
RequirementChange(_required);
}
/// @dev Allows an owner to submit and confirm a transaction.
/// @param destination Transaction target address.
/// @param value Transaction ether value.
/// @param data Transaction data payload.
/// @return Returns transaction ID.
function submitTransaction(address destination, uint value, bytes data)
public
returns (uint transactionId)
{
transactionId = addTransaction(destination, value, data);
confirmTransaction(transactionId);
}
/// @dev Allows an owner to confirm a transaction.
/// @param transactionId Transaction ID.
function confirmTransaction(uint transactionId)
public
ownerExists(msg.sender)
transactionExists(transactionId)
notConfirmed(transactionId, msg.sender)
{
confirmations[transactionId][msg.sender] = true;
Confirmation(msg.sender, transactionId);
executeTransaction(transactionId);
}
/// @dev Allows an owner to revoke a confirmation for a transaction.
/// @param transactionId Transaction ID.
function revokeConfirmation(uint transactionId)
public
ownerExists(msg.sender)
confirmed(transactionId, msg.sender)
notExecuted(transactionId)
{
confirmations[transactionId][msg.sender] = false;
Revocation(msg.sender, transactionId);
}
/// @dev Allows anyone to execute a confirmed transaction.
/// @param transactionId Transaction ID.
function executeTransaction(uint transactionId)
public
notExecuted(transactionId)
{
if (isConfirmed(transactionId)) {
Transaction tx = transactions[transactionId];
tx.executed = true;
if (tx.destination.call.value(tx.value)(tx.data))
Execution(transactionId);
else {
ExecutionFailure(transactionId);
tx.executed = false;
}
}
}
/// @dev Returns the confirmation status of a transaction.
/// @param transactionId Transaction ID.
/// @return Confirmation status.
function isConfirmed(uint transactionId)
public
constant
returns (bool)
{
uint count = 0;
for (uint i=0; i<owners.length; i++) {
if (confirmations[transactionId][owners[i]])
count += 1;
if (count == required)
return true;
}
}
/*
* Internal functions
*/
/// @dev Adds a new transaction to the transaction mapping, if transaction does not exist yet.
/// @param destination Transaction target address.
/// @param value Transaction ether value.
/// @param data Transaction data payload.
/// @return Returns transaction ID.
function addTransaction(address destination, uint value, bytes data)
internal
notNull(destination)
returns (uint transactionId)
{
transactionId = transactionCount;
transactions[transactionId] = Transaction({
destination: destination,
value: value,
data: data,
executed: false
});
transactionCount += 1;
Submission(transactionId);
}
/*
* Web3 call functions
*/
/// @dev Returns number of confirmations of a transaction.
/// @param transactionId Transaction ID.
/// @return Number of confirmations.
function getConfirmationCount(uint transactionId)
public
constant
returns (uint count)
{
for (uint i=0; i<owners.length; i++)
if (confirmations[transactionId][owners[i]])
count += 1;
}
/// @dev Returns total number of transactions after filers are applied.
/// @param pending Include pending transactions.
/// @param executed Include executed transactions.
/// @return Total number of transactions after filters are applied.
function getTransactionCount(bool pending, bool executed)
public
constant
returns (uint count)
{
for (uint i=0; i<transactionCount; i++)
if ( pending && !transactions[i].executed
|| executed && transactions[i].executed)
count += 1;
}
/// @dev Returns list of owners.
/// @return List of owner addresses.
function getOwners()
public
constant
returns (address[])
{
return owners;
}
/// @dev Returns array with owner addresses, which confirmed transaction.
/// @param transactionId Transaction ID.
/// @return Returns array of owner addresses.
function getConfirmations(uint transactionId)
public
constant
returns (address[] _confirmations)
{
address[] memory confirmationsTemp = new address[](owners.length);
uint count = 0;
uint i;
for (i=0; i<owners.length; i++)
if (confirmations[transactionId][owners[i]]) {
confirmationsTemp[count] = owners[i];
count += 1;
}
_confirmations = new address[](count);
for (i=0; i<count; i++)
_confirmations[i] = confirmationsTemp[i];
}
/// @dev Returns list of transaction IDs in defined range.
/// @param from Index start position of transaction array.
/// @param to Index end position of transaction array.
/// @param pending Include pending transactions.
/// @param executed Include executed transactions.
/// @return Returns array of transaction IDs.
function getTransactionIds(uint from, uint to, bool pending, bool executed)
public
constant
returns (uint[] _transactionIds)
{
uint[] memory transactionIdsTemp = new uint[](transactionCount);
uint count = 0;
uint i;
for (i=0; i<transactionCount; i++)
if ( pending && !transactions[i].executed
|| executed && transactions[i].executed)
{
transactionIdsTemp[count] = i;
count += 1;
}
_transactionIds = new uint[](to - from);
for (i=from; i<to; i++)
_transactionIds[i - from] = transactionIdsTemp[i];
}
/// @dev Create new coin.
function createCoin()
external
onlyWallet
{
require(flag == true);
CoinCreation(new Gifto());
flag = false;
}
} | /// @title Multisignature wallet - Allows multiple parties to agree on transactions before execution.
/// @author Stefan George - <[email protected]> | NatSpecSingleLine | isConfirmed | function isConfirmed(uint transactionId)
public
constant
returns (bool)
{
uint count = 0;
for (uint i=0; i<owners.length; i++) {
if (confirmations[transactionId][owners[i]])
count += 1;
if (count == required)
return true;
}
}
| /// @dev Returns the confirmation status of a transaction.
/// @param transactionId Transaction ID.
/// @return Confirmation status. | NatSpecSingleLine | v0.4.18+commit.9cf6e910 | bzzr://891e8485538f16f2fa5b9af11f8c795bc62d51fb6455063a6ee3652fa7680f20 | {
"func_code_index": [
7441,
7795
]
} | 3,543 |
|
MultiSigWallet | MultiSigWallet.sol | 0x615ed6779507f223d04722d43ccc0cd871964e2a | Solidity | MultiSigWallet | contract MultiSigWallet {
uint constant public MAX_OWNER_COUNT = 50;
event Confirmation(address indexed sender, uint indexed transactionId);
event Revocation(address indexed sender, uint indexed transactionId);
event Submission(uint indexed transactionId);
event Execution(uint indexed transactionId);
event ExecutionFailure(uint indexed transactionId);
event Deposit(address indexed sender, uint value);
event OwnerAddition(address indexed owner);
event OwnerRemoval(address indexed owner);
event RequirementChange(uint required);
event CoinCreation(address coin);
mapping (uint => Transaction) public transactions;
mapping (uint => mapping (address => bool)) public confirmations;
mapping (address => bool) public isOwner;
address[] public owners;
uint public required;
uint public transactionCount;
bool flag = true;
struct Transaction {
address destination;
uint value;
bytes data;
bool executed;
}
modifier onlyWallet() {
if (msg.sender != address(this))
revert();
_;
}
modifier ownerDoesNotExist(address owner) {
if (isOwner[owner])
revert();
_;
}
modifier ownerExists(address owner) {
if (!isOwner[owner])
revert();
_;
}
modifier transactionExists(uint transactionId) {
if (transactions[transactionId].destination == 0)
revert();
_;
}
modifier confirmed(uint transactionId, address owner) {
if (!confirmations[transactionId][owner])
revert();
_;
}
modifier notConfirmed(uint transactionId, address owner) {
if (confirmations[transactionId][owner])
revert();
_;
}
modifier notExecuted(uint transactionId) {
if (transactions[transactionId].executed)
revert();
_;
}
modifier notNull(address _address) {
if (_address == 0)
revert();
_;
}
modifier validRequirement(uint ownerCount, uint _required) {
if ( ownerCount > MAX_OWNER_COUNT
|| _required > ownerCount
|| _required == 0
|| ownerCount == 0)
revert();
_;
}
/// @dev Fallback function allows to deposit ether.
function()
payable
{
if (msg.value > 0)
Deposit(msg.sender, msg.value);
}
/*
* Public functions
*/
/// @dev Contract constructor sets initial owners and required number of confirmations.
/// @param _owners List of initial owners.
/// @param _required Number of required confirmations.
function MultiSigWallet(address[] _owners, uint _required)
public
validRequirement(_owners.length, _required)
{
for (uint i=0; i<_owners.length; i++) {
if (isOwner[_owners[i]] || _owners[i] == 0)
revert();
isOwner[_owners[i]] = true;
}
owners = _owners;
required = _required;
}
/// @dev Allows to add a new owner. Transaction has to be sent by wallet.
/// @param owner Address of new owner.
function addOwner(address owner)
public
onlyWallet
ownerDoesNotExist(owner)
notNull(owner)
validRequirement(owners.length + 1, required)
{
isOwner[owner] = true;
owners.push(owner);
OwnerAddition(owner);
}
/// @dev Allows to remove an owner. Transaction has to be sent by wallet.
/// @param owner Address of owner.
function removeOwner(address owner)
public
onlyWallet
ownerExists(owner)
{
isOwner[owner] = false;
for (uint i=0; i<owners.length - 1; i++)
if (owners[i] == owner) {
owners[i] = owners[owners.length - 1];
break;
}
owners.length -= 1;
if (required > owners.length)
changeRequirement(owners.length);
OwnerRemoval(owner);
}
/// @dev Allows to replace an owner with a new owner. Transaction has to be sent by wallet.
/// @param owner Address of owner to be replaced.
/// @param owner Address of new owner.
function replaceOwner(address owner, address newOwner)
public
onlyWallet
ownerExists(owner)
ownerDoesNotExist(newOwner)
{
for (uint i=0; i<owners.length; i++)
if (owners[i] == owner) {
owners[i] = newOwner;
break;
}
isOwner[owner] = false;
isOwner[newOwner] = true;
OwnerRemoval(owner);
OwnerAddition(newOwner);
}
/// @dev Allows to change the number of required confirmations. Transaction has to be sent by wallet.
/// @param _required Number of required confirmations.
function changeRequirement(uint _required)
public
onlyWallet
validRequirement(owners.length, _required)
{
required = _required;
RequirementChange(_required);
}
/// @dev Allows an owner to submit and confirm a transaction.
/// @param destination Transaction target address.
/// @param value Transaction ether value.
/// @param data Transaction data payload.
/// @return Returns transaction ID.
function submitTransaction(address destination, uint value, bytes data)
public
returns (uint transactionId)
{
transactionId = addTransaction(destination, value, data);
confirmTransaction(transactionId);
}
/// @dev Allows an owner to confirm a transaction.
/// @param transactionId Transaction ID.
function confirmTransaction(uint transactionId)
public
ownerExists(msg.sender)
transactionExists(transactionId)
notConfirmed(transactionId, msg.sender)
{
confirmations[transactionId][msg.sender] = true;
Confirmation(msg.sender, transactionId);
executeTransaction(transactionId);
}
/// @dev Allows an owner to revoke a confirmation for a transaction.
/// @param transactionId Transaction ID.
function revokeConfirmation(uint transactionId)
public
ownerExists(msg.sender)
confirmed(transactionId, msg.sender)
notExecuted(transactionId)
{
confirmations[transactionId][msg.sender] = false;
Revocation(msg.sender, transactionId);
}
/// @dev Allows anyone to execute a confirmed transaction.
/// @param transactionId Transaction ID.
function executeTransaction(uint transactionId)
public
notExecuted(transactionId)
{
if (isConfirmed(transactionId)) {
Transaction tx = transactions[transactionId];
tx.executed = true;
if (tx.destination.call.value(tx.value)(tx.data))
Execution(transactionId);
else {
ExecutionFailure(transactionId);
tx.executed = false;
}
}
}
/// @dev Returns the confirmation status of a transaction.
/// @param transactionId Transaction ID.
/// @return Confirmation status.
function isConfirmed(uint transactionId)
public
constant
returns (bool)
{
uint count = 0;
for (uint i=0; i<owners.length; i++) {
if (confirmations[transactionId][owners[i]])
count += 1;
if (count == required)
return true;
}
}
/*
* Internal functions
*/
/// @dev Adds a new transaction to the transaction mapping, if transaction does not exist yet.
/// @param destination Transaction target address.
/// @param value Transaction ether value.
/// @param data Transaction data payload.
/// @return Returns transaction ID.
function addTransaction(address destination, uint value, bytes data)
internal
notNull(destination)
returns (uint transactionId)
{
transactionId = transactionCount;
transactions[transactionId] = Transaction({
destination: destination,
value: value,
data: data,
executed: false
});
transactionCount += 1;
Submission(transactionId);
}
/*
* Web3 call functions
*/
/// @dev Returns number of confirmations of a transaction.
/// @param transactionId Transaction ID.
/// @return Number of confirmations.
function getConfirmationCount(uint transactionId)
public
constant
returns (uint count)
{
for (uint i=0; i<owners.length; i++)
if (confirmations[transactionId][owners[i]])
count += 1;
}
/// @dev Returns total number of transactions after filers are applied.
/// @param pending Include pending transactions.
/// @param executed Include executed transactions.
/// @return Total number of transactions after filters are applied.
function getTransactionCount(bool pending, bool executed)
public
constant
returns (uint count)
{
for (uint i=0; i<transactionCount; i++)
if ( pending && !transactions[i].executed
|| executed && transactions[i].executed)
count += 1;
}
/// @dev Returns list of owners.
/// @return List of owner addresses.
function getOwners()
public
constant
returns (address[])
{
return owners;
}
/// @dev Returns array with owner addresses, which confirmed transaction.
/// @param transactionId Transaction ID.
/// @return Returns array of owner addresses.
function getConfirmations(uint transactionId)
public
constant
returns (address[] _confirmations)
{
address[] memory confirmationsTemp = new address[](owners.length);
uint count = 0;
uint i;
for (i=0; i<owners.length; i++)
if (confirmations[transactionId][owners[i]]) {
confirmationsTemp[count] = owners[i];
count += 1;
}
_confirmations = new address[](count);
for (i=0; i<count; i++)
_confirmations[i] = confirmationsTemp[i];
}
/// @dev Returns list of transaction IDs in defined range.
/// @param from Index start position of transaction array.
/// @param to Index end position of transaction array.
/// @param pending Include pending transactions.
/// @param executed Include executed transactions.
/// @return Returns array of transaction IDs.
function getTransactionIds(uint from, uint to, bool pending, bool executed)
public
constant
returns (uint[] _transactionIds)
{
uint[] memory transactionIdsTemp = new uint[](transactionCount);
uint count = 0;
uint i;
for (i=0; i<transactionCount; i++)
if ( pending && !transactions[i].executed
|| executed && transactions[i].executed)
{
transactionIdsTemp[count] = i;
count += 1;
}
_transactionIds = new uint[](to - from);
for (i=from; i<to; i++)
_transactionIds[i - from] = transactionIdsTemp[i];
}
/// @dev Create new coin.
function createCoin()
external
onlyWallet
{
require(flag == true);
CoinCreation(new Gifto());
flag = false;
}
} | /// @title Multisignature wallet - Allows multiple parties to agree on transactions before execution.
/// @author Stefan George - <[email protected]> | NatSpecSingleLine | addTransaction | function addTransaction(address destination, uint value, bytes data)
internal
notNull(destination)
returns (uint transactionId)
{
transactionId = transactionCount;
transactions[transactionId] = Transaction({
destination: destination,
value: value,
data: data,
executed: false
});
transactionCount += 1;
Submission(transactionId);
}
| /// @dev Adds a new transaction to the transaction mapping, if transaction does not exist yet.
/// @param destination Transaction target address.
/// @param value Transaction ether value.
/// @param data Transaction data payload.
/// @return Returns transaction ID. | NatSpecSingleLine | v0.4.18+commit.9cf6e910 | bzzr://891e8485538f16f2fa5b9af11f8c795bc62d51fb6455063a6ee3652fa7680f20 | {
"func_code_index": [
8133,
8603
]
} | 3,544 |
|
MultiSigWallet | MultiSigWallet.sol | 0x615ed6779507f223d04722d43ccc0cd871964e2a | Solidity | MultiSigWallet | contract MultiSigWallet {
uint constant public MAX_OWNER_COUNT = 50;
event Confirmation(address indexed sender, uint indexed transactionId);
event Revocation(address indexed sender, uint indexed transactionId);
event Submission(uint indexed transactionId);
event Execution(uint indexed transactionId);
event ExecutionFailure(uint indexed transactionId);
event Deposit(address indexed sender, uint value);
event OwnerAddition(address indexed owner);
event OwnerRemoval(address indexed owner);
event RequirementChange(uint required);
event CoinCreation(address coin);
mapping (uint => Transaction) public transactions;
mapping (uint => mapping (address => bool)) public confirmations;
mapping (address => bool) public isOwner;
address[] public owners;
uint public required;
uint public transactionCount;
bool flag = true;
struct Transaction {
address destination;
uint value;
bytes data;
bool executed;
}
modifier onlyWallet() {
if (msg.sender != address(this))
revert();
_;
}
modifier ownerDoesNotExist(address owner) {
if (isOwner[owner])
revert();
_;
}
modifier ownerExists(address owner) {
if (!isOwner[owner])
revert();
_;
}
modifier transactionExists(uint transactionId) {
if (transactions[transactionId].destination == 0)
revert();
_;
}
modifier confirmed(uint transactionId, address owner) {
if (!confirmations[transactionId][owner])
revert();
_;
}
modifier notConfirmed(uint transactionId, address owner) {
if (confirmations[transactionId][owner])
revert();
_;
}
modifier notExecuted(uint transactionId) {
if (transactions[transactionId].executed)
revert();
_;
}
modifier notNull(address _address) {
if (_address == 0)
revert();
_;
}
modifier validRequirement(uint ownerCount, uint _required) {
if ( ownerCount > MAX_OWNER_COUNT
|| _required > ownerCount
|| _required == 0
|| ownerCount == 0)
revert();
_;
}
/// @dev Fallback function allows to deposit ether.
function()
payable
{
if (msg.value > 0)
Deposit(msg.sender, msg.value);
}
/*
* Public functions
*/
/// @dev Contract constructor sets initial owners and required number of confirmations.
/// @param _owners List of initial owners.
/// @param _required Number of required confirmations.
function MultiSigWallet(address[] _owners, uint _required)
public
validRequirement(_owners.length, _required)
{
for (uint i=0; i<_owners.length; i++) {
if (isOwner[_owners[i]] || _owners[i] == 0)
revert();
isOwner[_owners[i]] = true;
}
owners = _owners;
required = _required;
}
/// @dev Allows to add a new owner. Transaction has to be sent by wallet.
/// @param owner Address of new owner.
function addOwner(address owner)
public
onlyWallet
ownerDoesNotExist(owner)
notNull(owner)
validRequirement(owners.length + 1, required)
{
isOwner[owner] = true;
owners.push(owner);
OwnerAddition(owner);
}
/// @dev Allows to remove an owner. Transaction has to be sent by wallet.
/// @param owner Address of owner.
function removeOwner(address owner)
public
onlyWallet
ownerExists(owner)
{
isOwner[owner] = false;
for (uint i=0; i<owners.length - 1; i++)
if (owners[i] == owner) {
owners[i] = owners[owners.length - 1];
break;
}
owners.length -= 1;
if (required > owners.length)
changeRequirement(owners.length);
OwnerRemoval(owner);
}
/// @dev Allows to replace an owner with a new owner. Transaction has to be sent by wallet.
/// @param owner Address of owner to be replaced.
/// @param owner Address of new owner.
function replaceOwner(address owner, address newOwner)
public
onlyWallet
ownerExists(owner)
ownerDoesNotExist(newOwner)
{
for (uint i=0; i<owners.length; i++)
if (owners[i] == owner) {
owners[i] = newOwner;
break;
}
isOwner[owner] = false;
isOwner[newOwner] = true;
OwnerRemoval(owner);
OwnerAddition(newOwner);
}
/// @dev Allows to change the number of required confirmations. Transaction has to be sent by wallet.
/// @param _required Number of required confirmations.
function changeRequirement(uint _required)
public
onlyWallet
validRequirement(owners.length, _required)
{
required = _required;
RequirementChange(_required);
}
/// @dev Allows an owner to submit and confirm a transaction.
/// @param destination Transaction target address.
/// @param value Transaction ether value.
/// @param data Transaction data payload.
/// @return Returns transaction ID.
function submitTransaction(address destination, uint value, bytes data)
public
returns (uint transactionId)
{
transactionId = addTransaction(destination, value, data);
confirmTransaction(transactionId);
}
/// @dev Allows an owner to confirm a transaction.
/// @param transactionId Transaction ID.
function confirmTransaction(uint transactionId)
public
ownerExists(msg.sender)
transactionExists(transactionId)
notConfirmed(transactionId, msg.sender)
{
confirmations[transactionId][msg.sender] = true;
Confirmation(msg.sender, transactionId);
executeTransaction(transactionId);
}
/// @dev Allows an owner to revoke a confirmation for a transaction.
/// @param transactionId Transaction ID.
function revokeConfirmation(uint transactionId)
public
ownerExists(msg.sender)
confirmed(transactionId, msg.sender)
notExecuted(transactionId)
{
confirmations[transactionId][msg.sender] = false;
Revocation(msg.sender, transactionId);
}
/// @dev Allows anyone to execute a confirmed transaction.
/// @param transactionId Transaction ID.
function executeTransaction(uint transactionId)
public
notExecuted(transactionId)
{
if (isConfirmed(transactionId)) {
Transaction tx = transactions[transactionId];
tx.executed = true;
if (tx.destination.call.value(tx.value)(tx.data))
Execution(transactionId);
else {
ExecutionFailure(transactionId);
tx.executed = false;
}
}
}
/// @dev Returns the confirmation status of a transaction.
/// @param transactionId Transaction ID.
/// @return Confirmation status.
function isConfirmed(uint transactionId)
public
constant
returns (bool)
{
uint count = 0;
for (uint i=0; i<owners.length; i++) {
if (confirmations[transactionId][owners[i]])
count += 1;
if (count == required)
return true;
}
}
/*
* Internal functions
*/
/// @dev Adds a new transaction to the transaction mapping, if transaction does not exist yet.
/// @param destination Transaction target address.
/// @param value Transaction ether value.
/// @param data Transaction data payload.
/// @return Returns transaction ID.
function addTransaction(address destination, uint value, bytes data)
internal
notNull(destination)
returns (uint transactionId)
{
transactionId = transactionCount;
transactions[transactionId] = Transaction({
destination: destination,
value: value,
data: data,
executed: false
});
transactionCount += 1;
Submission(transactionId);
}
/*
* Web3 call functions
*/
/// @dev Returns number of confirmations of a transaction.
/// @param transactionId Transaction ID.
/// @return Number of confirmations.
function getConfirmationCount(uint transactionId)
public
constant
returns (uint count)
{
for (uint i=0; i<owners.length; i++)
if (confirmations[transactionId][owners[i]])
count += 1;
}
/// @dev Returns total number of transactions after filers are applied.
/// @param pending Include pending transactions.
/// @param executed Include executed transactions.
/// @return Total number of transactions after filters are applied.
function getTransactionCount(bool pending, bool executed)
public
constant
returns (uint count)
{
for (uint i=0; i<transactionCount; i++)
if ( pending && !transactions[i].executed
|| executed && transactions[i].executed)
count += 1;
}
/// @dev Returns list of owners.
/// @return List of owner addresses.
function getOwners()
public
constant
returns (address[])
{
return owners;
}
/// @dev Returns array with owner addresses, which confirmed transaction.
/// @param transactionId Transaction ID.
/// @return Returns array of owner addresses.
function getConfirmations(uint transactionId)
public
constant
returns (address[] _confirmations)
{
address[] memory confirmationsTemp = new address[](owners.length);
uint count = 0;
uint i;
for (i=0; i<owners.length; i++)
if (confirmations[transactionId][owners[i]]) {
confirmationsTemp[count] = owners[i];
count += 1;
}
_confirmations = new address[](count);
for (i=0; i<count; i++)
_confirmations[i] = confirmationsTemp[i];
}
/// @dev Returns list of transaction IDs in defined range.
/// @param from Index start position of transaction array.
/// @param to Index end position of transaction array.
/// @param pending Include pending transactions.
/// @param executed Include executed transactions.
/// @return Returns array of transaction IDs.
function getTransactionIds(uint from, uint to, bool pending, bool executed)
public
constant
returns (uint[] _transactionIds)
{
uint[] memory transactionIdsTemp = new uint[](transactionCount);
uint count = 0;
uint i;
for (i=0; i<transactionCount; i++)
if ( pending && !transactions[i].executed
|| executed && transactions[i].executed)
{
transactionIdsTemp[count] = i;
count += 1;
}
_transactionIds = new uint[](to - from);
for (i=from; i<to; i++)
_transactionIds[i - from] = transactionIdsTemp[i];
}
/// @dev Create new coin.
function createCoin()
external
onlyWallet
{
require(flag == true);
CoinCreation(new Gifto());
flag = false;
}
} | /// @title Multisignature wallet - Allows multiple parties to agree on transactions before execution.
/// @author Stefan George - <[email protected]> | NatSpecSingleLine | getConfirmationCount | function getConfirmationCount(uint transactionId)
public
constant
returns (uint count)
{
for (uint i=0; i<owners.length; i++)
if (confirmations[transactionId][owners[i]])
count += 1;
}
| /// @dev Returns number of confirmations of a transaction.
/// @param transactionId Transaction ID.
/// @return Number of confirmations. | NatSpecSingleLine | v0.4.18+commit.9cf6e910 | bzzr://891e8485538f16f2fa5b9af11f8c795bc62d51fb6455063a6ee3652fa7680f20 | {
"func_code_index": [
8803,
9068
]
} | 3,545 |
|
MultiSigWallet | MultiSigWallet.sol | 0x615ed6779507f223d04722d43ccc0cd871964e2a | Solidity | MultiSigWallet | contract MultiSigWallet {
uint constant public MAX_OWNER_COUNT = 50;
event Confirmation(address indexed sender, uint indexed transactionId);
event Revocation(address indexed sender, uint indexed transactionId);
event Submission(uint indexed transactionId);
event Execution(uint indexed transactionId);
event ExecutionFailure(uint indexed transactionId);
event Deposit(address indexed sender, uint value);
event OwnerAddition(address indexed owner);
event OwnerRemoval(address indexed owner);
event RequirementChange(uint required);
event CoinCreation(address coin);
mapping (uint => Transaction) public transactions;
mapping (uint => mapping (address => bool)) public confirmations;
mapping (address => bool) public isOwner;
address[] public owners;
uint public required;
uint public transactionCount;
bool flag = true;
struct Transaction {
address destination;
uint value;
bytes data;
bool executed;
}
modifier onlyWallet() {
if (msg.sender != address(this))
revert();
_;
}
modifier ownerDoesNotExist(address owner) {
if (isOwner[owner])
revert();
_;
}
modifier ownerExists(address owner) {
if (!isOwner[owner])
revert();
_;
}
modifier transactionExists(uint transactionId) {
if (transactions[transactionId].destination == 0)
revert();
_;
}
modifier confirmed(uint transactionId, address owner) {
if (!confirmations[transactionId][owner])
revert();
_;
}
modifier notConfirmed(uint transactionId, address owner) {
if (confirmations[transactionId][owner])
revert();
_;
}
modifier notExecuted(uint transactionId) {
if (transactions[transactionId].executed)
revert();
_;
}
modifier notNull(address _address) {
if (_address == 0)
revert();
_;
}
modifier validRequirement(uint ownerCount, uint _required) {
if ( ownerCount > MAX_OWNER_COUNT
|| _required > ownerCount
|| _required == 0
|| ownerCount == 0)
revert();
_;
}
/// @dev Fallback function allows to deposit ether.
function()
payable
{
if (msg.value > 0)
Deposit(msg.sender, msg.value);
}
/*
* Public functions
*/
/// @dev Contract constructor sets initial owners and required number of confirmations.
/// @param _owners List of initial owners.
/// @param _required Number of required confirmations.
function MultiSigWallet(address[] _owners, uint _required)
public
validRequirement(_owners.length, _required)
{
for (uint i=0; i<_owners.length; i++) {
if (isOwner[_owners[i]] || _owners[i] == 0)
revert();
isOwner[_owners[i]] = true;
}
owners = _owners;
required = _required;
}
/// @dev Allows to add a new owner. Transaction has to be sent by wallet.
/// @param owner Address of new owner.
function addOwner(address owner)
public
onlyWallet
ownerDoesNotExist(owner)
notNull(owner)
validRequirement(owners.length + 1, required)
{
isOwner[owner] = true;
owners.push(owner);
OwnerAddition(owner);
}
/// @dev Allows to remove an owner. Transaction has to be sent by wallet.
/// @param owner Address of owner.
function removeOwner(address owner)
public
onlyWallet
ownerExists(owner)
{
isOwner[owner] = false;
for (uint i=0; i<owners.length - 1; i++)
if (owners[i] == owner) {
owners[i] = owners[owners.length - 1];
break;
}
owners.length -= 1;
if (required > owners.length)
changeRequirement(owners.length);
OwnerRemoval(owner);
}
/// @dev Allows to replace an owner with a new owner. Transaction has to be sent by wallet.
/// @param owner Address of owner to be replaced.
/// @param owner Address of new owner.
function replaceOwner(address owner, address newOwner)
public
onlyWallet
ownerExists(owner)
ownerDoesNotExist(newOwner)
{
for (uint i=0; i<owners.length; i++)
if (owners[i] == owner) {
owners[i] = newOwner;
break;
}
isOwner[owner] = false;
isOwner[newOwner] = true;
OwnerRemoval(owner);
OwnerAddition(newOwner);
}
/// @dev Allows to change the number of required confirmations. Transaction has to be sent by wallet.
/// @param _required Number of required confirmations.
function changeRequirement(uint _required)
public
onlyWallet
validRequirement(owners.length, _required)
{
required = _required;
RequirementChange(_required);
}
/// @dev Allows an owner to submit and confirm a transaction.
/// @param destination Transaction target address.
/// @param value Transaction ether value.
/// @param data Transaction data payload.
/// @return Returns transaction ID.
function submitTransaction(address destination, uint value, bytes data)
public
returns (uint transactionId)
{
transactionId = addTransaction(destination, value, data);
confirmTransaction(transactionId);
}
/// @dev Allows an owner to confirm a transaction.
/// @param transactionId Transaction ID.
function confirmTransaction(uint transactionId)
public
ownerExists(msg.sender)
transactionExists(transactionId)
notConfirmed(transactionId, msg.sender)
{
confirmations[transactionId][msg.sender] = true;
Confirmation(msg.sender, transactionId);
executeTransaction(transactionId);
}
/// @dev Allows an owner to revoke a confirmation for a transaction.
/// @param transactionId Transaction ID.
function revokeConfirmation(uint transactionId)
public
ownerExists(msg.sender)
confirmed(transactionId, msg.sender)
notExecuted(transactionId)
{
confirmations[transactionId][msg.sender] = false;
Revocation(msg.sender, transactionId);
}
/// @dev Allows anyone to execute a confirmed transaction.
/// @param transactionId Transaction ID.
function executeTransaction(uint transactionId)
public
notExecuted(transactionId)
{
if (isConfirmed(transactionId)) {
Transaction tx = transactions[transactionId];
tx.executed = true;
if (tx.destination.call.value(tx.value)(tx.data))
Execution(transactionId);
else {
ExecutionFailure(transactionId);
tx.executed = false;
}
}
}
/// @dev Returns the confirmation status of a transaction.
/// @param transactionId Transaction ID.
/// @return Confirmation status.
function isConfirmed(uint transactionId)
public
constant
returns (bool)
{
uint count = 0;
for (uint i=0; i<owners.length; i++) {
if (confirmations[transactionId][owners[i]])
count += 1;
if (count == required)
return true;
}
}
/*
* Internal functions
*/
/// @dev Adds a new transaction to the transaction mapping, if transaction does not exist yet.
/// @param destination Transaction target address.
/// @param value Transaction ether value.
/// @param data Transaction data payload.
/// @return Returns transaction ID.
function addTransaction(address destination, uint value, bytes data)
internal
notNull(destination)
returns (uint transactionId)
{
transactionId = transactionCount;
transactions[transactionId] = Transaction({
destination: destination,
value: value,
data: data,
executed: false
});
transactionCount += 1;
Submission(transactionId);
}
/*
* Web3 call functions
*/
/// @dev Returns number of confirmations of a transaction.
/// @param transactionId Transaction ID.
/// @return Number of confirmations.
function getConfirmationCount(uint transactionId)
public
constant
returns (uint count)
{
for (uint i=0; i<owners.length; i++)
if (confirmations[transactionId][owners[i]])
count += 1;
}
/// @dev Returns total number of transactions after filers are applied.
/// @param pending Include pending transactions.
/// @param executed Include executed transactions.
/// @return Total number of transactions after filters are applied.
function getTransactionCount(bool pending, bool executed)
public
constant
returns (uint count)
{
for (uint i=0; i<transactionCount; i++)
if ( pending && !transactions[i].executed
|| executed && transactions[i].executed)
count += 1;
}
/// @dev Returns list of owners.
/// @return List of owner addresses.
function getOwners()
public
constant
returns (address[])
{
return owners;
}
/// @dev Returns array with owner addresses, which confirmed transaction.
/// @param transactionId Transaction ID.
/// @return Returns array of owner addresses.
function getConfirmations(uint transactionId)
public
constant
returns (address[] _confirmations)
{
address[] memory confirmationsTemp = new address[](owners.length);
uint count = 0;
uint i;
for (i=0; i<owners.length; i++)
if (confirmations[transactionId][owners[i]]) {
confirmationsTemp[count] = owners[i];
count += 1;
}
_confirmations = new address[](count);
for (i=0; i<count; i++)
_confirmations[i] = confirmationsTemp[i];
}
/// @dev Returns list of transaction IDs in defined range.
/// @param from Index start position of transaction array.
/// @param to Index end position of transaction array.
/// @param pending Include pending transactions.
/// @param executed Include executed transactions.
/// @return Returns array of transaction IDs.
function getTransactionIds(uint from, uint to, bool pending, bool executed)
public
constant
returns (uint[] _transactionIds)
{
uint[] memory transactionIdsTemp = new uint[](transactionCount);
uint count = 0;
uint i;
for (i=0; i<transactionCount; i++)
if ( pending && !transactions[i].executed
|| executed && transactions[i].executed)
{
transactionIdsTemp[count] = i;
count += 1;
}
_transactionIds = new uint[](to - from);
for (i=from; i<to; i++)
_transactionIds[i - from] = transactionIdsTemp[i];
}
/// @dev Create new coin.
function createCoin()
external
onlyWallet
{
require(flag == true);
CoinCreation(new Gifto());
flag = false;
}
} | /// @title Multisignature wallet - Allows multiple parties to agree on transactions before execution.
/// @author Stefan George - <[email protected]> | NatSpecSingleLine | getTransactionCount | function getTransactionCount(bool pending, bool executed)
public
constant
returns (uint count)
{
for (uint i=0; i<transactionCount; i++)
if ( pending && !transactions[i].executed
|| executed && transactions[i].executed)
count += 1;
}
| /// @dev Returns total number of transactions after filers are applied.
/// @param pending Include pending transactions.
/// @param executed Include executed transactions.
/// @return Total number of transactions after filters are applied. | NatSpecSingleLine | v0.4.18+commit.9cf6e910 | bzzr://891e8485538f16f2fa5b9af11f8c795bc62d51fb6455063a6ee3652fa7680f20 | {
"func_code_index": [
9331,
9664
]
} | 3,546 |
|
MultiSigWallet | MultiSigWallet.sol | 0x615ed6779507f223d04722d43ccc0cd871964e2a | Solidity | MultiSigWallet | contract MultiSigWallet {
uint constant public MAX_OWNER_COUNT = 50;
event Confirmation(address indexed sender, uint indexed transactionId);
event Revocation(address indexed sender, uint indexed transactionId);
event Submission(uint indexed transactionId);
event Execution(uint indexed transactionId);
event ExecutionFailure(uint indexed transactionId);
event Deposit(address indexed sender, uint value);
event OwnerAddition(address indexed owner);
event OwnerRemoval(address indexed owner);
event RequirementChange(uint required);
event CoinCreation(address coin);
mapping (uint => Transaction) public transactions;
mapping (uint => mapping (address => bool)) public confirmations;
mapping (address => bool) public isOwner;
address[] public owners;
uint public required;
uint public transactionCount;
bool flag = true;
struct Transaction {
address destination;
uint value;
bytes data;
bool executed;
}
modifier onlyWallet() {
if (msg.sender != address(this))
revert();
_;
}
modifier ownerDoesNotExist(address owner) {
if (isOwner[owner])
revert();
_;
}
modifier ownerExists(address owner) {
if (!isOwner[owner])
revert();
_;
}
modifier transactionExists(uint transactionId) {
if (transactions[transactionId].destination == 0)
revert();
_;
}
modifier confirmed(uint transactionId, address owner) {
if (!confirmations[transactionId][owner])
revert();
_;
}
modifier notConfirmed(uint transactionId, address owner) {
if (confirmations[transactionId][owner])
revert();
_;
}
modifier notExecuted(uint transactionId) {
if (transactions[transactionId].executed)
revert();
_;
}
modifier notNull(address _address) {
if (_address == 0)
revert();
_;
}
modifier validRequirement(uint ownerCount, uint _required) {
if ( ownerCount > MAX_OWNER_COUNT
|| _required > ownerCount
|| _required == 0
|| ownerCount == 0)
revert();
_;
}
/// @dev Fallback function allows to deposit ether.
function()
payable
{
if (msg.value > 0)
Deposit(msg.sender, msg.value);
}
/*
* Public functions
*/
/// @dev Contract constructor sets initial owners and required number of confirmations.
/// @param _owners List of initial owners.
/// @param _required Number of required confirmations.
function MultiSigWallet(address[] _owners, uint _required)
public
validRequirement(_owners.length, _required)
{
for (uint i=0; i<_owners.length; i++) {
if (isOwner[_owners[i]] || _owners[i] == 0)
revert();
isOwner[_owners[i]] = true;
}
owners = _owners;
required = _required;
}
/// @dev Allows to add a new owner. Transaction has to be sent by wallet.
/// @param owner Address of new owner.
function addOwner(address owner)
public
onlyWallet
ownerDoesNotExist(owner)
notNull(owner)
validRequirement(owners.length + 1, required)
{
isOwner[owner] = true;
owners.push(owner);
OwnerAddition(owner);
}
/// @dev Allows to remove an owner. Transaction has to be sent by wallet.
/// @param owner Address of owner.
function removeOwner(address owner)
public
onlyWallet
ownerExists(owner)
{
isOwner[owner] = false;
for (uint i=0; i<owners.length - 1; i++)
if (owners[i] == owner) {
owners[i] = owners[owners.length - 1];
break;
}
owners.length -= 1;
if (required > owners.length)
changeRequirement(owners.length);
OwnerRemoval(owner);
}
/// @dev Allows to replace an owner with a new owner. Transaction has to be sent by wallet.
/// @param owner Address of owner to be replaced.
/// @param owner Address of new owner.
function replaceOwner(address owner, address newOwner)
public
onlyWallet
ownerExists(owner)
ownerDoesNotExist(newOwner)
{
for (uint i=0; i<owners.length; i++)
if (owners[i] == owner) {
owners[i] = newOwner;
break;
}
isOwner[owner] = false;
isOwner[newOwner] = true;
OwnerRemoval(owner);
OwnerAddition(newOwner);
}
/// @dev Allows to change the number of required confirmations. Transaction has to be sent by wallet.
/// @param _required Number of required confirmations.
function changeRequirement(uint _required)
public
onlyWallet
validRequirement(owners.length, _required)
{
required = _required;
RequirementChange(_required);
}
/// @dev Allows an owner to submit and confirm a transaction.
/// @param destination Transaction target address.
/// @param value Transaction ether value.
/// @param data Transaction data payload.
/// @return Returns transaction ID.
function submitTransaction(address destination, uint value, bytes data)
public
returns (uint transactionId)
{
transactionId = addTransaction(destination, value, data);
confirmTransaction(transactionId);
}
/// @dev Allows an owner to confirm a transaction.
/// @param transactionId Transaction ID.
function confirmTransaction(uint transactionId)
public
ownerExists(msg.sender)
transactionExists(transactionId)
notConfirmed(transactionId, msg.sender)
{
confirmations[transactionId][msg.sender] = true;
Confirmation(msg.sender, transactionId);
executeTransaction(transactionId);
}
/// @dev Allows an owner to revoke a confirmation for a transaction.
/// @param transactionId Transaction ID.
function revokeConfirmation(uint transactionId)
public
ownerExists(msg.sender)
confirmed(transactionId, msg.sender)
notExecuted(transactionId)
{
confirmations[transactionId][msg.sender] = false;
Revocation(msg.sender, transactionId);
}
/// @dev Allows anyone to execute a confirmed transaction.
/// @param transactionId Transaction ID.
function executeTransaction(uint transactionId)
public
notExecuted(transactionId)
{
if (isConfirmed(transactionId)) {
Transaction tx = transactions[transactionId];
tx.executed = true;
if (tx.destination.call.value(tx.value)(tx.data))
Execution(transactionId);
else {
ExecutionFailure(transactionId);
tx.executed = false;
}
}
}
/// @dev Returns the confirmation status of a transaction.
/// @param transactionId Transaction ID.
/// @return Confirmation status.
function isConfirmed(uint transactionId)
public
constant
returns (bool)
{
uint count = 0;
for (uint i=0; i<owners.length; i++) {
if (confirmations[transactionId][owners[i]])
count += 1;
if (count == required)
return true;
}
}
/*
* Internal functions
*/
/// @dev Adds a new transaction to the transaction mapping, if transaction does not exist yet.
/// @param destination Transaction target address.
/// @param value Transaction ether value.
/// @param data Transaction data payload.
/// @return Returns transaction ID.
function addTransaction(address destination, uint value, bytes data)
internal
notNull(destination)
returns (uint transactionId)
{
transactionId = transactionCount;
transactions[transactionId] = Transaction({
destination: destination,
value: value,
data: data,
executed: false
});
transactionCount += 1;
Submission(transactionId);
}
/*
* Web3 call functions
*/
/// @dev Returns number of confirmations of a transaction.
/// @param transactionId Transaction ID.
/// @return Number of confirmations.
function getConfirmationCount(uint transactionId)
public
constant
returns (uint count)
{
for (uint i=0; i<owners.length; i++)
if (confirmations[transactionId][owners[i]])
count += 1;
}
/// @dev Returns total number of transactions after filers are applied.
/// @param pending Include pending transactions.
/// @param executed Include executed transactions.
/// @return Total number of transactions after filters are applied.
function getTransactionCount(bool pending, bool executed)
public
constant
returns (uint count)
{
for (uint i=0; i<transactionCount; i++)
if ( pending && !transactions[i].executed
|| executed && transactions[i].executed)
count += 1;
}
/// @dev Returns list of owners.
/// @return List of owner addresses.
function getOwners()
public
constant
returns (address[])
{
return owners;
}
/// @dev Returns array with owner addresses, which confirmed transaction.
/// @param transactionId Transaction ID.
/// @return Returns array of owner addresses.
function getConfirmations(uint transactionId)
public
constant
returns (address[] _confirmations)
{
address[] memory confirmationsTemp = new address[](owners.length);
uint count = 0;
uint i;
for (i=0; i<owners.length; i++)
if (confirmations[transactionId][owners[i]]) {
confirmationsTemp[count] = owners[i];
count += 1;
}
_confirmations = new address[](count);
for (i=0; i<count; i++)
_confirmations[i] = confirmationsTemp[i];
}
/// @dev Returns list of transaction IDs in defined range.
/// @param from Index start position of transaction array.
/// @param to Index end position of transaction array.
/// @param pending Include pending transactions.
/// @param executed Include executed transactions.
/// @return Returns array of transaction IDs.
function getTransactionIds(uint from, uint to, bool pending, bool executed)
public
constant
returns (uint[] _transactionIds)
{
uint[] memory transactionIdsTemp = new uint[](transactionCount);
uint count = 0;
uint i;
for (i=0; i<transactionCount; i++)
if ( pending && !transactions[i].executed
|| executed && transactions[i].executed)
{
transactionIdsTemp[count] = i;
count += 1;
}
_transactionIds = new uint[](to - from);
for (i=from; i<to; i++)
_transactionIds[i - from] = transactionIdsTemp[i];
}
/// @dev Create new coin.
function createCoin()
external
onlyWallet
{
require(flag == true);
CoinCreation(new Gifto());
flag = false;
}
} | /// @title Multisignature wallet - Allows multiple parties to agree on transactions before execution.
/// @author Stefan George - <[email protected]> | NatSpecSingleLine | getOwners | function getOwners()
public
constant
returns (address[])
{
return owners;
}
| /// @dev Returns list of owners.
/// @return List of owner addresses. | NatSpecSingleLine | v0.4.18+commit.9cf6e910 | bzzr://891e8485538f16f2fa5b9af11f8c795bc62d51fb6455063a6ee3652fa7680f20 | {
"func_code_index": [
9747,
9873
]
} | 3,547 |
|
MultiSigWallet | MultiSigWallet.sol | 0x615ed6779507f223d04722d43ccc0cd871964e2a | Solidity | MultiSigWallet | contract MultiSigWallet {
uint constant public MAX_OWNER_COUNT = 50;
event Confirmation(address indexed sender, uint indexed transactionId);
event Revocation(address indexed sender, uint indexed transactionId);
event Submission(uint indexed transactionId);
event Execution(uint indexed transactionId);
event ExecutionFailure(uint indexed transactionId);
event Deposit(address indexed sender, uint value);
event OwnerAddition(address indexed owner);
event OwnerRemoval(address indexed owner);
event RequirementChange(uint required);
event CoinCreation(address coin);
mapping (uint => Transaction) public transactions;
mapping (uint => mapping (address => bool)) public confirmations;
mapping (address => bool) public isOwner;
address[] public owners;
uint public required;
uint public transactionCount;
bool flag = true;
struct Transaction {
address destination;
uint value;
bytes data;
bool executed;
}
modifier onlyWallet() {
if (msg.sender != address(this))
revert();
_;
}
modifier ownerDoesNotExist(address owner) {
if (isOwner[owner])
revert();
_;
}
modifier ownerExists(address owner) {
if (!isOwner[owner])
revert();
_;
}
modifier transactionExists(uint transactionId) {
if (transactions[transactionId].destination == 0)
revert();
_;
}
modifier confirmed(uint transactionId, address owner) {
if (!confirmations[transactionId][owner])
revert();
_;
}
modifier notConfirmed(uint transactionId, address owner) {
if (confirmations[transactionId][owner])
revert();
_;
}
modifier notExecuted(uint transactionId) {
if (transactions[transactionId].executed)
revert();
_;
}
modifier notNull(address _address) {
if (_address == 0)
revert();
_;
}
modifier validRequirement(uint ownerCount, uint _required) {
if ( ownerCount > MAX_OWNER_COUNT
|| _required > ownerCount
|| _required == 0
|| ownerCount == 0)
revert();
_;
}
/// @dev Fallback function allows to deposit ether.
function()
payable
{
if (msg.value > 0)
Deposit(msg.sender, msg.value);
}
/*
* Public functions
*/
/// @dev Contract constructor sets initial owners and required number of confirmations.
/// @param _owners List of initial owners.
/// @param _required Number of required confirmations.
function MultiSigWallet(address[] _owners, uint _required)
public
validRequirement(_owners.length, _required)
{
for (uint i=0; i<_owners.length; i++) {
if (isOwner[_owners[i]] || _owners[i] == 0)
revert();
isOwner[_owners[i]] = true;
}
owners = _owners;
required = _required;
}
/// @dev Allows to add a new owner. Transaction has to be sent by wallet.
/// @param owner Address of new owner.
function addOwner(address owner)
public
onlyWallet
ownerDoesNotExist(owner)
notNull(owner)
validRequirement(owners.length + 1, required)
{
isOwner[owner] = true;
owners.push(owner);
OwnerAddition(owner);
}
/// @dev Allows to remove an owner. Transaction has to be sent by wallet.
/// @param owner Address of owner.
function removeOwner(address owner)
public
onlyWallet
ownerExists(owner)
{
isOwner[owner] = false;
for (uint i=0; i<owners.length - 1; i++)
if (owners[i] == owner) {
owners[i] = owners[owners.length - 1];
break;
}
owners.length -= 1;
if (required > owners.length)
changeRequirement(owners.length);
OwnerRemoval(owner);
}
/// @dev Allows to replace an owner with a new owner. Transaction has to be sent by wallet.
/// @param owner Address of owner to be replaced.
/// @param owner Address of new owner.
function replaceOwner(address owner, address newOwner)
public
onlyWallet
ownerExists(owner)
ownerDoesNotExist(newOwner)
{
for (uint i=0; i<owners.length; i++)
if (owners[i] == owner) {
owners[i] = newOwner;
break;
}
isOwner[owner] = false;
isOwner[newOwner] = true;
OwnerRemoval(owner);
OwnerAddition(newOwner);
}
/// @dev Allows to change the number of required confirmations. Transaction has to be sent by wallet.
/// @param _required Number of required confirmations.
function changeRequirement(uint _required)
public
onlyWallet
validRequirement(owners.length, _required)
{
required = _required;
RequirementChange(_required);
}
/// @dev Allows an owner to submit and confirm a transaction.
/// @param destination Transaction target address.
/// @param value Transaction ether value.
/// @param data Transaction data payload.
/// @return Returns transaction ID.
function submitTransaction(address destination, uint value, bytes data)
public
returns (uint transactionId)
{
transactionId = addTransaction(destination, value, data);
confirmTransaction(transactionId);
}
/// @dev Allows an owner to confirm a transaction.
/// @param transactionId Transaction ID.
function confirmTransaction(uint transactionId)
public
ownerExists(msg.sender)
transactionExists(transactionId)
notConfirmed(transactionId, msg.sender)
{
confirmations[transactionId][msg.sender] = true;
Confirmation(msg.sender, transactionId);
executeTransaction(transactionId);
}
/// @dev Allows an owner to revoke a confirmation for a transaction.
/// @param transactionId Transaction ID.
function revokeConfirmation(uint transactionId)
public
ownerExists(msg.sender)
confirmed(transactionId, msg.sender)
notExecuted(transactionId)
{
confirmations[transactionId][msg.sender] = false;
Revocation(msg.sender, transactionId);
}
/// @dev Allows anyone to execute a confirmed transaction.
/// @param transactionId Transaction ID.
function executeTransaction(uint transactionId)
public
notExecuted(transactionId)
{
if (isConfirmed(transactionId)) {
Transaction tx = transactions[transactionId];
tx.executed = true;
if (tx.destination.call.value(tx.value)(tx.data))
Execution(transactionId);
else {
ExecutionFailure(transactionId);
tx.executed = false;
}
}
}
/// @dev Returns the confirmation status of a transaction.
/// @param transactionId Transaction ID.
/// @return Confirmation status.
function isConfirmed(uint transactionId)
public
constant
returns (bool)
{
uint count = 0;
for (uint i=0; i<owners.length; i++) {
if (confirmations[transactionId][owners[i]])
count += 1;
if (count == required)
return true;
}
}
/*
* Internal functions
*/
/// @dev Adds a new transaction to the transaction mapping, if transaction does not exist yet.
/// @param destination Transaction target address.
/// @param value Transaction ether value.
/// @param data Transaction data payload.
/// @return Returns transaction ID.
function addTransaction(address destination, uint value, bytes data)
internal
notNull(destination)
returns (uint transactionId)
{
transactionId = transactionCount;
transactions[transactionId] = Transaction({
destination: destination,
value: value,
data: data,
executed: false
});
transactionCount += 1;
Submission(transactionId);
}
/*
* Web3 call functions
*/
/// @dev Returns number of confirmations of a transaction.
/// @param transactionId Transaction ID.
/// @return Number of confirmations.
function getConfirmationCount(uint transactionId)
public
constant
returns (uint count)
{
for (uint i=0; i<owners.length; i++)
if (confirmations[transactionId][owners[i]])
count += 1;
}
/// @dev Returns total number of transactions after filers are applied.
/// @param pending Include pending transactions.
/// @param executed Include executed transactions.
/// @return Total number of transactions after filters are applied.
function getTransactionCount(bool pending, bool executed)
public
constant
returns (uint count)
{
for (uint i=0; i<transactionCount; i++)
if ( pending && !transactions[i].executed
|| executed && transactions[i].executed)
count += 1;
}
/// @dev Returns list of owners.
/// @return List of owner addresses.
function getOwners()
public
constant
returns (address[])
{
return owners;
}
/// @dev Returns array with owner addresses, which confirmed transaction.
/// @param transactionId Transaction ID.
/// @return Returns array of owner addresses.
function getConfirmations(uint transactionId)
public
constant
returns (address[] _confirmations)
{
address[] memory confirmationsTemp = new address[](owners.length);
uint count = 0;
uint i;
for (i=0; i<owners.length; i++)
if (confirmations[transactionId][owners[i]]) {
confirmationsTemp[count] = owners[i];
count += 1;
}
_confirmations = new address[](count);
for (i=0; i<count; i++)
_confirmations[i] = confirmationsTemp[i];
}
/// @dev Returns list of transaction IDs in defined range.
/// @param from Index start position of transaction array.
/// @param to Index end position of transaction array.
/// @param pending Include pending transactions.
/// @param executed Include executed transactions.
/// @return Returns array of transaction IDs.
function getTransactionIds(uint from, uint to, bool pending, bool executed)
public
constant
returns (uint[] _transactionIds)
{
uint[] memory transactionIdsTemp = new uint[](transactionCount);
uint count = 0;
uint i;
for (i=0; i<transactionCount; i++)
if ( pending && !transactions[i].executed
|| executed && transactions[i].executed)
{
transactionIdsTemp[count] = i;
count += 1;
}
_transactionIds = new uint[](to - from);
for (i=from; i<to; i++)
_transactionIds[i - from] = transactionIdsTemp[i];
}
/// @dev Create new coin.
function createCoin()
external
onlyWallet
{
require(flag == true);
CoinCreation(new Gifto());
flag = false;
}
} | /// @title Multisignature wallet - Allows multiple parties to agree on transactions before execution.
/// @author Stefan George - <[email protected]> | NatSpecSingleLine | getConfirmations | function getConfirmations(uint transactionId)
public
constant
returns (address[] _confirmations)
{
address[] memory confirmationsTemp = new address[](owners.length);
uint count = 0;
uint i;
for (i=0; i<owners.length; i++)
if (confirmations[transactionId][owners[i]]) {
confirmationsTemp[count] = owners[i];
count += 1;
}
_confirmations = new address[](count);
for (i=0; i<count; i++)
_confirmations[i] = confirmationsTemp[i];
}
| /// @dev Returns array with owner addresses, which confirmed transaction.
/// @param transactionId Transaction ID.
/// @return Returns array of owner addresses. | NatSpecSingleLine | v0.4.18+commit.9cf6e910 | bzzr://891e8485538f16f2fa5b9af11f8c795bc62d51fb6455063a6ee3652fa7680f20 | {
"func_code_index": [
10052,
10648
]
} | 3,548 |
|
MultiSigWallet | MultiSigWallet.sol | 0x615ed6779507f223d04722d43ccc0cd871964e2a | Solidity | MultiSigWallet | contract MultiSigWallet {
uint constant public MAX_OWNER_COUNT = 50;
event Confirmation(address indexed sender, uint indexed transactionId);
event Revocation(address indexed sender, uint indexed transactionId);
event Submission(uint indexed transactionId);
event Execution(uint indexed transactionId);
event ExecutionFailure(uint indexed transactionId);
event Deposit(address indexed sender, uint value);
event OwnerAddition(address indexed owner);
event OwnerRemoval(address indexed owner);
event RequirementChange(uint required);
event CoinCreation(address coin);
mapping (uint => Transaction) public transactions;
mapping (uint => mapping (address => bool)) public confirmations;
mapping (address => bool) public isOwner;
address[] public owners;
uint public required;
uint public transactionCount;
bool flag = true;
struct Transaction {
address destination;
uint value;
bytes data;
bool executed;
}
modifier onlyWallet() {
if (msg.sender != address(this))
revert();
_;
}
modifier ownerDoesNotExist(address owner) {
if (isOwner[owner])
revert();
_;
}
modifier ownerExists(address owner) {
if (!isOwner[owner])
revert();
_;
}
modifier transactionExists(uint transactionId) {
if (transactions[transactionId].destination == 0)
revert();
_;
}
modifier confirmed(uint transactionId, address owner) {
if (!confirmations[transactionId][owner])
revert();
_;
}
modifier notConfirmed(uint transactionId, address owner) {
if (confirmations[transactionId][owner])
revert();
_;
}
modifier notExecuted(uint transactionId) {
if (transactions[transactionId].executed)
revert();
_;
}
modifier notNull(address _address) {
if (_address == 0)
revert();
_;
}
modifier validRequirement(uint ownerCount, uint _required) {
if ( ownerCount > MAX_OWNER_COUNT
|| _required > ownerCount
|| _required == 0
|| ownerCount == 0)
revert();
_;
}
/// @dev Fallback function allows to deposit ether.
function()
payable
{
if (msg.value > 0)
Deposit(msg.sender, msg.value);
}
/*
* Public functions
*/
/// @dev Contract constructor sets initial owners and required number of confirmations.
/// @param _owners List of initial owners.
/// @param _required Number of required confirmations.
function MultiSigWallet(address[] _owners, uint _required)
public
validRequirement(_owners.length, _required)
{
for (uint i=0; i<_owners.length; i++) {
if (isOwner[_owners[i]] || _owners[i] == 0)
revert();
isOwner[_owners[i]] = true;
}
owners = _owners;
required = _required;
}
/// @dev Allows to add a new owner. Transaction has to be sent by wallet.
/// @param owner Address of new owner.
function addOwner(address owner)
public
onlyWallet
ownerDoesNotExist(owner)
notNull(owner)
validRequirement(owners.length + 1, required)
{
isOwner[owner] = true;
owners.push(owner);
OwnerAddition(owner);
}
/// @dev Allows to remove an owner. Transaction has to be sent by wallet.
/// @param owner Address of owner.
function removeOwner(address owner)
public
onlyWallet
ownerExists(owner)
{
isOwner[owner] = false;
for (uint i=0; i<owners.length - 1; i++)
if (owners[i] == owner) {
owners[i] = owners[owners.length - 1];
break;
}
owners.length -= 1;
if (required > owners.length)
changeRequirement(owners.length);
OwnerRemoval(owner);
}
/// @dev Allows to replace an owner with a new owner. Transaction has to be sent by wallet.
/// @param owner Address of owner to be replaced.
/// @param owner Address of new owner.
function replaceOwner(address owner, address newOwner)
public
onlyWallet
ownerExists(owner)
ownerDoesNotExist(newOwner)
{
for (uint i=0; i<owners.length; i++)
if (owners[i] == owner) {
owners[i] = newOwner;
break;
}
isOwner[owner] = false;
isOwner[newOwner] = true;
OwnerRemoval(owner);
OwnerAddition(newOwner);
}
/// @dev Allows to change the number of required confirmations. Transaction has to be sent by wallet.
/// @param _required Number of required confirmations.
function changeRequirement(uint _required)
public
onlyWallet
validRequirement(owners.length, _required)
{
required = _required;
RequirementChange(_required);
}
/// @dev Allows an owner to submit and confirm a transaction.
/// @param destination Transaction target address.
/// @param value Transaction ether value.
/// @param data Transaction data payload.
/// @return Returns transaction ID.
function submitTransaction(address destination, uint value, bytes data)
public
returns (uint transactionId)
{
transactionId = addTransaction(destination, value, data);
confirmTransaction(transactionId);
}
/// @dev Allows an owner to confirm a transaction.
/// @param transactionId Transaction ID.
function confirmTransaction(uint transactionId)
public
ownerExists(msg.sender)
transactionExists(transactionId)
notConfirmed(transactionId, msg.sender)
{
confirmations[transactionId][msg.sender] = true;
Confirmation(msg.sender, transactionId);
executeTransaction(transactionId);
}
/// @dev Allows an owner to revoke a confirmation for a transaction.
/// @param transactionId Transaction ID.
function revokeConfirmation(uint transactionId)
public
ownerExists(msg.sender)
confirmed(transactionId, msg.sender)
notExecuted(transactionId)
{
confirmations[transactionId][msg.sender] = false;
Revocation(msg.sender, transactionId);
}
/// @dev Allows anyone to execute a confirmed transaction.
/// @param transactionId Transaction ID.
function executeTransaction(uint transactionId)
public
notExecuted(transactionId)
{
if (isConfirmed(transactionId)) {
Transaction tx = transactions[transactionId];
tx.executed = true;
if (tx.destination.call.value(tx.value)(tx.data))
Execution(transactionId);
else {
ExecutionFailure(transactionId);
tx.executed = false;
}
}
}
/// @dev Returns the confirmation status of a transaction.
/// @param transactionId Transaction ID.
/// @return Confirmation status.
function isConfirmed(uint transactionId)
public
constant
returns (bool)
{
uint count = 0;
for (uint i=0; i<owners.length; i++) {
if (confirmations[transactionId][owners[i]])
count += 1;
if (count == required)
return true;
}
}
/*
* Internal functions
*/
/// @dev Adds a new transaction to the transaction mapping, if transaction does not exist yet.
/// @param destination Transaction target address.
/// @param value Transaction ether value.
/// @param data Transaction data payload.
/// @return Returns transaction ID.
function addTransaction(address destination, uint value, bytes data)
internal
notNull(destination)
returns (uint transactionId)
{
transactionId = transactionCount;
transactions[transactionId] = Transaction({
destination: destination,
value: value,
data: data,
executed: false
});
transactionCount += 1;
Submission(transactionId);
}
/*
* Web3 call functions
*/
/// @dev Returns number of confirmations of a transaction.
/// @param transactionId Transaction ID.
/// @return Number of confirmations.
function getConfirmationCount(uint transactionId)
public
constant
returns (uint count)
{
for (uint i=0; i<owners.length; i++)
if (confirmations[transactionId][owners[i]])
count += 1;
}
/// @dev Returns total number of transactions after filers are applied.
/// @param pending Include pending transactions.
/// @param executed Include executed transactions.
/// @return Total number of transactions after filters are applied.
function getTransactionCount(bool pending, bool executed)
public
constant
returns (uint count)
{
for (uint i=0; i<transactionCount; i++)
if ( pending && !transactions[i].executed
|| executed && transactions[i].executed)
count += 1;
}
/// @dev Returns list of owners.
/// @return List of owner addresses.
function getOwners()
public
constant
returns (address[])
{
return owners;
}
/// @dev Returns array with owner addresses, which confirmed transaction.
/// @param transactionId Transaction ID.
/// @return Returns array of owner addresses.
function getConfirmations(uint transactionId)
public
constant
returns (address[] _confirmations)
{
address[] memory confirmationsTemp = new address[](owners.length);
uint count = 0;
uint i;
for (i=0; i<owners.length; i++)
if (confirmations[transactionId][owners[i]]) {
confirmationsTemp[count] = owners[i];
count += 1;
}
_confirmations = new address[](count);
for (i=0; i<count; i++)
_confirmations[i] = confirmationsTemp[i];
}
/// @dev Returns list of transaction IDs in defined range.
/// @param from Index start position of transaction array.
/// @param to Index end position of transaction array.
/// @param pending Include pending transactions.
/// @param executed Include executed transactions.
/// @return Returns array of transaction IDs.
function getTransactionIds(uint from, uint to, bool pending, bool executed)
public
constant
returns (uint[] _transactionIds)
{
uint[] memory transactionIdsTemp = new uint[](transactionCount);
uint count = 0;
uint i;
for (i=0; i<transactionCount; i++)
if ( pending && !transactions[i].executed
|| executed && transactions[i].executed)
{
transactionIdsTemp[count] = i;
count += 1;
}
_transactionIds = new uint[](to - from);
for (i=from; i<to; i++)
_transactionIds[i - from] = transactionIdsTemp[i];
}
/// @dev Create new coin.
function createCoin()
external
onlyWallet
{
require(flag == true);
CoinCreation(new Gifto());
flag = false;
}
} | /// @title Multisignature wallet - Allows multiple parties to agree on transactions before execution.
/// @author Stefan George - <[email protected]> | NatSpecSingleLine | getTransactionIds | function getTransactionIds(uint from, uint to, bool pending, bool executed)
public
constant
returns (uint[] _transactionIds)
{
uint[] memory transactionIdsTemp = new uint[](transactionCount);
uint count = 0;
uint i;
for (i=0; i<transactionCount; i++)
if ( pending && !transactions[i].executed
|| executed && transactions[i].executed)
{
transactionIdsTemp[count] = i;
count += 1;
}
_transactionIds = new uint[](to - from);
for (i=from; i<to; i++)
_transactionIds[i - from] = transactionIdsTemp[i];
}
| /// @dev Returns list of transaction IDs in defined range.
/// @param from Index start position of transaction array.
/// @param to Index end position of transaction array.
/// @param pending Include pending transactions.
/// @param executed Include executed transactions.
/// @return Returns array of transaction IDs. | NatSpecSingleLine | v0.4.18+commit.9cf6e910 | bzzr://891e8485538f16f2fa5b9af11f8c795bc62d51fb6455063a6ee3652fa7680f20 | {
"func_code_index": [
11000,
11699
]
} | 3,549 |
|
MultiSigWallet | MultiSigWallet.sol | 0x615ed6779507f223d04722d43ccc0cd871964e2a | Solidity | MultiSigWallet | contract MultiSigWallet {
uint constant public MAX_OWNER_COUNT = 50;
event Confirmation(address indexed sender, uint indexed transactionId);
event Revocation(address indexed sender, uint indexed transactionId);
event Submission(uint indexed transactionId);
event Execution(uint indexed transactionId);
event ExecutionFailure(uint indexed transactionId);
event Deposit(address indexed sender, uint value);
event OwnerAddition(address indexed owner);
event OwnerRemoval(address indexed owner);
event RequirementChange(uint required);
event CoinCreation(address coin);
mapping (uint => Transaction) public transactions;
mapping (uint => mapping (address => bool)) public confirmations;
mapping (address => bool) public isOwner;
address[] public owners;
uint public required;
uint public transactionCount;
bool flag = true;
struct Transaction {
address destination;
uint value;
bytes data;
bool executed;
}
modifier onlyWallet() {
if (msg.sender != address(this))
revert();
_;
}
modifier ownerDoesNotExist(address owner) {
if (isOwner[owner])
revert();
_;
}
modifier ownerExists(address owner) {
if (!isOwner[owner])
revert();
_;
}
modifier transactionExists(uint transactionId) {
if (transactions[transactionId].destination == 0)
revert();
_;
}
modifier confirmed(uint transactionId, address owner) {
if (!confirmations[transactionId][owner])
revert();
_;
}
modifier notConfirmed(uint transactionId, address owner) {
if (confirmations[transactionId][owner])
revert();
_;
}
modifier notExecuted(uint transactionId) {
if (transactions[transactionId].executed)
revert();
_;
}
modifier notNull(address _address) {
if (_address == 0)
revert();
_;
}
modifier validRequirement(uint ownerCount, uint _required) {
if ( ownerCount > MAX_OWNER_COUNT
|| _required > ownerCount
|| _required == 0
|| ownerCount == 0)
revert();
_;
}
/// @dev Fallback function allows to deposit ether.
function()
payable
{
if (msg.value > 0)
Deposit(msg.sender, msg.value);
}
/*
* Public functions
*/
/// @dev Contract constructor sets initial owners and required number of confirmations.
/// @param _owners List of initial owners.
/// @param _required Number of required confirmations.
function MultiSigWallet(address[] _owners, uint _required)
public
validRequirement(_owners.length, _required)
{
for (uint i=0; i<_owners.length; i++) {
if (isOwner[_owners[i]] || _owners[i] == 0)
revert();
isOwner[_owners[i]] = true;
}
owners = _owners;
required = _required;
}
/// @dev Allows to add a new owner. Transaction has to be sent by wallet.
/// @param owner Address of new owner.
function addOwner(address owner)
public
onlyWallet
ownerDoesNotExist(owner)
notNull(owner)
validRequirement(owners.length + 1, required)
{
isOwner[owner] = true;
owners.push(owner);
OwnerAddition(owner);
}
/// @dev Allows to remove an owner. Transaction has to be sent by wallet.
/// @param owner Address of owner.
function removeOwner(address owner)
public
onlyWallet
ownerExists(owner)
{
isOwner[owner] = false;
for (uint i=0; i<owners.length - 1; i++)
if (owners[i] == owner) {
owners[i] = owners[owners.length - 1];
break;
}
owners.length -= 1;
if (required > owners.length)
changeRequirement(owners.length);
OwnerRemoval(owner);
}
/// @dev Allows to replace an owner with a new owner. Transaction has to be sent by wallet.
/// @param owner Address of owner to be replaced.
/// @param owner Address of new owner.
function replaceOwner(address owner, address newOwner)
public
onlyWallet
ownerExists(owner)
ownerDoesNotExist(newOwner)
{
for (uint i=0; i<owners.length; i++)
if (owners[i] == owner) {
owners[i] = newOwner;
break;
}
isOwner[owner] = false;
isOwner[newOwner] = true;
OwnerRemoval(owner);
OwnerAddition(newOwner);
}
/// @dev Allows to change the number of required confirmations. Transaction has to be sent by wallet.
/// @param _required Number of required confirmations.
function changeRequirement(uint _required)
public
onlyWallet
validRequirement(owners.length, _required)
{
required = _required;
RequirementChange(_required);
}
/// @dev Allows an owner to submit and confirm a transaction.
/// @param destination Transaction target address.
/// @param value Transaction ether value.
/// @param data Transaction data payload.
/// @return Returns transaction ID.
function submitTransaction(address destination, uint value, bytes data)
public
returns (uint transactionId)
{
transactionId = addTransaction(destination, value, data);
confirmTransaction(transactionId);
}
/// @dev Allows an owner to confirm a transaction.
/// @param transactionId Transaction ID.
function confirmTransaction(uint transactionId)
public
ownerExists(msg.sender)
transactionExists(transactionId)
notConfirmed(transactionId, msg.sender)
{
confirmations[transactionId][msg.sender] = true;
Confirmation(msg.sender, transactionId);
executeTransaction(transactionId);
}
/// @dev Allows an owner to revoke a confirmation for a transaction.
/// @param transactionId Transaction ID.
function revokeConfirmation(uint transactionId)
public
ownerExists(msg.sender)
confirmed(transactionId, msg.sender)
notExecuted(transactionId)
{
confirmations[transactionId][msg.sender] = false;
Revocation(msg.sender, transactionId);
}
/// @dev Allows anyone to execute a confirmed transaction.
/// @param transactionId Transaction ID.
function executeTransaction(uint transactionId)
public
notExecuted(transactionId)
{
if (isConfirmed(transactionId)) {
Transaction tx = transactions[transactionId];
tx.executed = true;
if (tx.destination.call.value(tx.value)(tx.data))
Execution(transactionId);
else {
ExecutionFailure(transactionId);
tx.executed = false;
}
}
}
/// @dev Returns the confirmation status of a transaction.
/// @param transactionId Transaction ID.
/// @return Confirmation status.
function isConfirmed(uint transactionId)
public
constant
returns (bool)
{
uint count = 0;
for (uint i=0; i<owners.length; i++) {
if (confirmations[transactionId][owners[i]])
count += 1;
if (count == required)
return true;
}
}
/*
* Internal functions
*/
/// @dev Adds a new transaction to the transaction mapping, if transaction does not exist yet.
/// @param destination Transaction target address.
/// @param value Transaction ether value.
/// @param data Transaction data payload.
/// @return Returns transaction ID.
function addTransaction(address destination, uint value, bytes data)
internal
notNull(destination)
returns (uint transactionId)
{
transactionId = transactionCount;
transactions[transactionId] = Transaction({
destination: destination,
value: value,
data: data,
executed: false
});
transactionCount += 1;
Submission(transactionId);
}
/*
* Web3 call functions
*/
/// @dev Returns number of confirmations of a transaction.
/// @param transactionId Transaction ID.
/// @return Number of confirmations.
function getConfirmationCount(uint transactionId)
public
constant
returns (uint count)
{
for (uint i=0; i<owners.length; i++)
if (confirmations[transactionId][owners[i]])
count += 1;
}
/// @dev Returns total number of transactions after filers are applied.
/// @param pending Include pending transactions.
/// @param executed Include executed transactions.
/// @return Total number of transactions after filters are applied.
function getTransactionCount(bool pending, bool executed)
public
constant
returns (uint count)
{
for (uint i=0; i<transactionCount; i++)
if ( pending && !transactions[i].executed
|| executed && transactions[i].executed)
count += 1;
}
/// @dev Returns list of owners.
/// @return List of owner addresses.
function getOwners()
public
constant
returns (address[])
{
return owners;
}
/// @dev Returns array with owner addresses, which confirmed transaction.
/// @param transactionId Transaction ID.
/// @return Returns array of owner addresses.
function getConfirmations(uint transactionId)
public
constant
returns (address[] _confirmations)
{
address[] memory confirmationsTemp = new address[](owners.length);
uint count = 0;
uint i;
for (i=0; i<owners.length; i++)
if (confirmations[transactionId][owners[i]]) {
confirmationsTemp[count] = owners[i];
count += 1;
}
_confirmations = new address[](count);
for (i=0; i<count; i++)
_confirmations[i] = confirmationsTemp[i];
}
/// @dev Returns list of transaction IDs in defined range.
/// @param from Index start position of transaction array.
/// @param to Index end position of transaction array.
/// @param pending Include pending transactions.
/// @param executed Include executed transactions.
/// @return Returns array of transaction IDs.
function getTransactionIds(uint from, uint to, bool pending, bool executed)
public
constant
returns (uint[] _transactionIds)
{
uint[] memory transactionIdsTemp = new uint[](transactionCount);
uint count = 0;
uint i;
for (i=0; i<transactionCount; i++)
if ( pending && !transactions[i].executed
|| executed && transactions[i].executed)
{
transactionIdsTemp[count] = i;
count += 1;
}
_transactionIds = new uint[](to - from);
for (i=from; i<to; i++)
_transactionIds[i - from] = transactionIdsTemp[i];
}
/// @dev Create new coin.
function createCoin()
external
onlyWallet
{
require(flag == true);
CoinCreation(new Gifto());
flag = false;
}
} | /// @title Multisignature wallet - Allows multiple parties to agree on transactions before execution.
/// @author Stefan George - <[email protected]> | NatSpecSingleLine | createCoin | function createCoin()
external
onlyWallet
{
require(flag == true);
CoinCreation(new Gifto());
flag = false;
}
| /// @dev Create new coin. | NatSpecSingleLine | v0.4.18+commit.9cf6e910 | bzzr://891e8485538f16f2fa5b9af11f8c795bc62d51fb6455063a6ee3652fa7680f20 | {
"func_code_index": [
11737,
11906
]
} | 3,550 |
|
AaveImport | contracts/exchangeV3/DFSExchangeHelper.sol | 0x751961666d8605af1c5ee549205f822f47b04168 | Solidity | DFSExchangeHelper | contract DFSExchangeHelper {
using SafeERC20 for ERC20;
address public constant KYBER_ETH_ADDRESS = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE;
address public constant WETH_ADDRESS = 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2;
address payable public constant WALLET_ID = 0x322d58b9E75a6918f7e7849AEe0fF09369977e08;
address public constant DISCOUNT_ADDRESS = 0x1b14E8D511c9A4395425314f849bD737BAF8208F;
address public constant SAVER_EXCHANGE_REGISTRY = 0x25dd3F51e0C3c3Ff164DDC02A8E4D65Bb9cBB12D;
address public constant ZRX_ALLOWLIST_ADDR = 0x4BA1f38427b33B8ab7Bb0490200dAE1F1C36823F;
function getDecimals(address _token) internal view returns (uint256) {
if (_token == KYBER_ETH_ADDRESS) return 18;
return ERC20(_token).decimals();
}
function getBalance(address _tokenAddr) internal view returns (uint balance) {
if (_tokenAddr == KYBER_ETH_ADDRESS) {
balance = address(this).balance;
} else {
balance = ERC20(_tokenAddr).balanceOf(address(this));
}
}
function sendLeftover(address _srcAddr, address _destAddr, address payable _to) internal {
// send back any leftover ether or tokens
if (address(this).balance > 0) {
_to.transfer(address(this).balance);
}
if (getBalance(_srcAddr) > 0) {
ERC20(_srcAddr).safeTransfer(_to, getBalance(_srcAddr));
}
if (getBalance(_destAddr) > 0) {
ERC20(_destAddr).safeTransfer(_to, getBalance(_destAddr));
}
}
/// @notice Takes a feePercentage and sends it to wallet
/// @param _amount Dai amount of the whole trade
/// @param _user Address of the user
/// @param _token Address of the token
/// @param _dfsFeeDivider Dfs fee divider
/// @return feeAmount Amount in Dai owner earned on the fee
function getFee(uint256 _amount, address _user, address _token, uint256 _dfsFeeDivider) internal returns (uint256 feeAmount) {
if (_dfsFeeDivider != 0 && Discount(DISCOUNT_ADDRESS).isCustomFeeSet(_user)) {
_dfsFeeDivider = Discount(DISCOUNT_ADDRESS).getCustomServiceFee(_user);
}
if (_dfsFeeDivider == 0) {
feeAmount = 0;
} else {
feeAmount = _amount / _dfsFeeDivider;
// fee can't go over 10% of the whole amount
if (feeAmount > (_amount / 10)) {
feeAmount = _amount / 10;
}
if (_token == KYBER_ETH_ADDRESS) {
WALLET_ID.transfer(feeAmount);
} else {
ERC20(_token).safeTransfer(WALLET_ID, feeAmount);
}
}
}
function sliceUint(bytes memory bs, uint256 start) internal pure returns (uint256) {
require(bs.length >= start + 32, "slicing out of range");
uint256 x;
assembly {
x := mload(add(bs, add(0x20, start)))
}
return x;
}
} | getFee | function getFee(uint256 _amount, address _user, address _token, uint256 _dfsFeeDivider) internal returns (uint256 feeAmount) {
if (_dfsFeeDivider != 0 && Discount(DISCOUNT_ADDRESS).isCustomFeeSet(_user)) {
_dfsFeeDivider = Discount(DISCOUNT_ADDRESS).getCustomServiceFee(_user);
}
if (_dfsFeeDivider == 0) {
feeAmount = 0;
} else {
feeAmount = _amount / _dfsFeeDivider;
// fee can't go over 10% of the whole amount
if (feeAmount > (_amount / 10)) {
feeAmount = _amount / 10;
}
if (_token == KYBER_ETH_ADDRESS) {
WALLET_ID.transfer(feeAmount);
} else {
ERC20(_token).safeTransfer(WALLET_ID, feeAmount);
}
}
}
| /// @notice Takes a feePercentage and sends it to wallet
/// @param _amount Dai amount of the whole trade
/// @param _user Address of the user
/// @param _token Address of the token
/// @param _dfsFeeDivider Dfs fee divider
/// @return feeAmount Amount in Dai owner earned on the fee | NatSpecSingleLine | v0.6.12+commit.27d51765 | MIT | ipfs://34c42220a035234e7357a4f4dce033d4f7741dd29565a8d77139b7fde50d3c09 | {
"func_code_index": [
1873,
2686
]
} | 3,551 |
||
Treecle | Treecle.sol | 0x0a9d68886a0d7db83a30ec00d62512483e5ad437 | Solidity | SafeMath | library SafeMath {
/**
* @dev Multiplies two unsigned integers, reverts on overflow.
*/
function mul(uint256 _a, uint256 _b) internal pure returns (uint256) {
if (_a == 0) {
return 0;
}
uint256 c = _a * _b;
require(c / _a == _b);
return c;
}
/**
* @dev Integer division of two unsigned integers truncating the quotient, reverts on division by zero.
*/
function div(uint256 _a, uint256 _b) internal pure returns (uint256) {
// Solidity only automatically asserts when dividing by 0
require(_b > 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 unsigned integers, reverts on overflow (i.e. if subtrahend is greater than minuend).
*/
function sub(uint256 _a, uint256 _b) internal pure returns (uint256) {
require(_b <= _a);
return _a - _b;
}
/**
* @dev Adds two unsigned integers, 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 unsigned integers 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) {
if (_a == 0) {
return 0;
}
uint256 c = _a * _b;
require(c / _a == _b);
return c;
}
| /**
* @dev Multiplies two unsigned integers, reverts on overflow.
*/ | NatSpecMultiLine | v0.4.24+commit.e67f0147 | None | bzzr://95748fa07458c5b3c131a227a282ace64e0b0ecddd929fea9ab17bee4e82a0a6 | {
"func_code_index": [
103,
268
]
} | 3,552 |
||
Treecle | Treecle.sol | 0x0a9d68886a0d7db83a30ec00d62512483e5ad437 | Solidity | SafeMath | library SafeMath {
/**
* @dev Multiplies two unsigned integers, reverts on overflow.
*/
function mul(uint256 _a, uint256 _b) internal pure returns (uint256) {
if (_a == 0) {
return 0;
}
uint256 c = _a * _b;
require(c / _a == _b);
return c;
}
/**
* @dev Integer division of two unsigned integers truncating the quotient, reverts on division by zero.
*/
function div(uint256 _a, uint256 _b) internal pure returns (uint256) {
// Solidity only automatically asserts when dividing by 0
require(_b > 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 unsigned integers, reverts on overflow (i.e. if subtrahend is greater than minuend).
*/
function sub(uint256 _a, uint256 _b) internal pure returns (uint256) {
require(_b <= _a);
return _a - _b;
}
/**
* @dev Adds two unsigned integers, 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 unsigned integers 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) {
// Solidity only automatically asserts when dividing by 0
require(_b > 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 unsigned integers truncating the quotient, reverts on division by zero.
*/ | NatSpecMultiLine | v0.4.24+commit.e67f0147 | None | bzzr://95748fa07458c5b3c131a227a282ace64e0b0ecddd929fea9ab17bee4e82a0a6 | {
"func_code_index": [
389,
655
]
} | 3,553 |
||
Treecle | Treecle.sol | 0x0a9d68886a0d7db83a30ec00d62512483e5ad437 | Solidity | SafeMath | library SafeMath {
/**
* @dev Multiplies two unsigned integers, reverts on overflow.
*/
function mul(uint256 _a, uint256 _b) internal pure returns (uint256) {
if (_a == 0) {
return 0;
}
uint256 c = _a * _b;
require(c / _a == _b);
return c;
}
/**
* @dev Integer division of two unsigned integers truncating the quotient, reverts on division by zero.
*/
function div(uint256 _a, uint256 _b) internal pure returns (uint256) {
// Solidity only automatically asserts when dividing by 0
require(_b > 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 unsigned integers, reverts on overflow (i.e. if subtrahend is greater than minuend).
*/
function sub(uint256 _a, uint256 _b) internal pure returns (uint256) {
require(_b <= _a);
return _a - _b;
}
/**
* @dev Adds two unsigned integers, 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 unsigned integers 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);
return _a - _b;
}
| /**
* @dev Subtracts two unsigned integers, reverts on overflow (i.e. if subtrahend is greater than minuend).
*/ | NatSpecMultiLine | v0.4.24+commit.e67f0147 | None | bzzr://95748fa07458c5b3c131a227a282ace64e0b0ecddd929fea9ab17bee4e82a0a6 | {
"func_code_index": [
783,
896
]
} | 3,554 |
||
Treecle | Treecle.sol | 0x0a9d68886a0d7db83a30ec00d62512483e5ad437 | Solidity | SafeMath | library SafeMath {
/**
* @dev Multiplies two unsigned integers, reverts on overflow.
*/
function mul(uint256 _a, uint256 _b) internal pure returns (uint256) {
if (_a == 0) {
return 0;
}
uint256 c = _a * _b;
require(c / _a == _b);
return c;
}
/**
* @dev Integer division of two unsigned integers truncating the quotient, reverts on division by zero.
*/
function div(uint256 _a, uint256 _b) internal pure returns (uint256) {
// Solidity only automatically asserts when dividing by 0
require(_b > 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 unsigned integers, reverts on overflow (i.e. if subtrahend is greater than minuend).
*/
function sub(uint256 _a, uint256 _b) internal pure returns (uint256) {
require(_b <= _a);
return _a - _b;
}
/**
* @dev Adds two unsigned integers, 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 unsigned integers 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 unsigned integers, reverts on overflow.
*/ | NatSpecMultiLine | v0.4.24+commit.e67f0147 | None | bzzr://95748fa07458c5b3c131a227a282ace64e0b0ecddd929fea9ab17bee4e82a0a6 | {
"func_code_index": [
970,
1100
]
} | 3,555 |
||
Treecle | Treecle.sol | 0x0a9d68886a0d7db83a30ec00d62512483e5ad437 | Solidity | SafeMath | library SafeMath {
/**
* @dev Multiplies two unsigned integers, reverts on overflow.
*/
function mul(uint256 _a, uint256 _b) internal pure returns (uint256) {
if (_a == 0) {
return 0;
}
uint256 c = _a * _b;
require(c / _a == _b);
return c;
}
/**
* @dev Integer division of two unsigned integers truncating the quotient, reverts on division by zero.
*/
function div(uint256 _a, uint256 _b) internal pure returns (uint256) {
// Solidity only automatically asserts when dividing by 0
require(_b > 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 unsigned integers, reverts on overflow (i.e. if subtrahend is greater than minuend).
*/
function sub(uint256 _a, uint256 _b) internal pure returns (uint256) {
require(_b <= _a);
return _a - _b;
}
/**
* @dev Adds two unsigned integers, 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 unsigned integers 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 unsigned integers and returns the remainder (unsigned integer modulo),
* reverts when dividing by zero.
*/ | NatSpecMultiLine | v0.4.24+commit.e67f0147 | None | bzzr://95748fa07458c5b3c131a227a282ace64e0b0ecddd929fea9ab17bee4e82a0a6 | {
"func_code_index": [
1244,
1357
]
} | 3,556 |
||
Treecle | Treecle.sol | 0x0a9d68886a0d7db83a30ec00d62512483e5ad437 | Solidity | Ownable | contract Ownable {
address public owner;
address public newOwner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
constructor() public {
owner = msg.sender;
newOwner = address(0);
}
// allows execution by the owner only
modifier onlyOwner() {
require(msg.sender == owner);
_;
}
modifier onlyNewOwner() {
require(msg.sender != address(0));
require(msg.sender == newOwner);
_;
}
/**
@dev allows transferring the contract ownership
the new owner still needs to accept the transfer
can only be called by the contract owner
@param _newOwner new contract owner
*/
function transferOwnership(address _newOwner) public onlyOwner {
require(_newOwner != address(0));
newOwner = _newOwner;
}
/**
@dev used by a new owner to accept an ownership transfer
*/
function acceptOwnership() public onlyNewOwner {
emit OwnershipTransferred(owner, newOwner);
owner = newOwner;
}
} | /*
* Ownable
*
* Base contract with an owner.
* Provides onlyOwner modifier, which prevents function from running if it is called by anyone other than the owner.
*/ | Comment | transferOwnership | function transferOwnership(address _newOwner) public onlyOwner {
require(_newOwner != address(0));
newOwner = _newOwner;
}
| /**
@dev allows transferring the contract ownership
the new owner still needs to accept the transfer
can only be called by the contract owner
@param _newOwner new contract owner
*/ | NatSpecMultiLine | v0.4.24+commit.e67f0147 | None | bzzr://95748fa07458c5b3c131a227a282ace64e0b0ecddd929fea9ab17bee4e82a0a6 | {
"func_code_index": [
652,
778
]
} | 3,557 |
Treecle | Treecle.sol | 0x0a9d68886a0d7db83a30ec00d62512483e5ad437 | Solidity | Ownable | contract Ownable {
address public owner;
address public newOwner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
constructor() public {
owner = msg.sender;
newOwner = address(0);
}
// allows execution by the owner only
modifier onlyOwner() {
require(msg.sender == owner);
_;
}
modifier onlyNewOwner() {
require(msg.sender != address(0));
require(msg.sender == newOwner);
_;
}
/**
@dev allows transferring the contract ownership
the new owner still needs to accept the transfer
can only be called by the contract owner
@param _newOwner new contract owner
*/
function transferOwnership(address _newOwner) public onlyOwner {
require(_newOwner != address(0));
newOwner = _newOwner;
}
/**
@dev used by a new owner to accept an ownership transfer
*/
function acceptOwnership() public onlyNewOwner {
emit OwnershipTransferred(owner, newOwner);
owner = newOwner;
}
} | /*
* Ownable
*
* Base contract with an owner.
* Provides onlyOwner modifier, which prevents function from running if it is called by anyone other than the owner.
*/ | Comment | acceptOwnership | function acceptOwnership() public onlyNewOwner {
emit OwnershipTransferred(owner, newOwner);
owner = newOwner;
}
| /**
@dev used by a new owner to accept an ownership transfer
*/ | NatSpecMultiLine | v0.4.24+commit.e67f0147 | None | bzzr://95748fa07458c5b3c131a227a282ace64e0b0ecddd929fea9ab17bee4e82a0a6 | {
"func_code_index": [
854,
970
]
} | 3,558 |
Treecle | Treecle.sol | 0x0a9d68886a0d7db83a30ec00d62512483e5ad437 | Solidity | Treecle | contract Treecle is ERC20, Ownable {
using SafeMath for uint256;
string public name;
string public symbol;
uint8 public decimals;
uint256 internal initialSupply;
uint256 internal totalSupply_;
mapping(address => uint256) internal balances;
mapping(address => bool) public frozen;
mapping(address => mapping(address => uint256)) internal allowed;
event Burn(address indexed owner, uint256 value);
event Freeze(address indexed holder);
event Unfreeze(address indexed holder);
modifier notFrozen(address _holder) {
require(!frozen[_holder]);
_;
}
constructor() public {
name = "Treecle";
symbol = "TRCL";
decimals = 0;
initialSupply = 2000000000;
totalSupply_ = 2000000000;
balances[owner] = totalSupply_;
emit Transfer(address(0), owner, totalSupply_);
}
function () public payable {
revert();
}
/**
* @dev Total number of tokens in existence
*/
function totalSupply() public view returns (uint256) {
return totalSupply_;
}
/**
* @dev Transfer token for a specified addresses
* @param _from The address to transfer from.
* @param _to The address to transfer to.
* @param _value The amount to be transferred.
*/
function _transfer(address _from, address _to, uint _value) internal {
require(_to != address(0));
require(_value <= balances[_from]);
require(_value <= allowed[_from][msg.sender]);
balances[_from] = balances[_from].sub(_value);
balances[_to] = balances[_to].add(_value);
allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value);
emit Transfer(_from, _to, _value);
}
/**
* @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 notFrozen(msg.sender) returns (bool) {
require(_to != address(0));
require(_value <= balances[msg.sender]);
balances[msg.sender] = balances[msg.sender].sub(_value);
balances[_to] = balances[_to].add(_value);
emit Transfer(msg.sender, _to, _value);
return true;
}
/**
* @dev Gets the balance of the specified address.
* @param _holder The address to query the balance of.
* @return An uint256 representing the amount owned by the passed address.
*/
function balanceOf(address _holder) public view returns (uint256 balance) {
return balances[_holder];
}
/**
* @dev Transfer tokens from one address to another.
* Note that while this function emits an Approval event, this is not required as per the specification,
* and other compliant implementations may not emit the event.
* @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 notFrozen(_from) returns (bool) {
require(_to != address(0));
require(_value <= balances[_from]);
require(_value <= allowed[_from][msg.sender]);
_transfer(_from, _to, _value);
return true;
}
/**
* @dev Approve the passed address to _spender the specified amount of tokens on behalf of msg.sender.
* Beware that changing an allowance with this method brings the risk that someone may use both the old
* and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this
* race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
* @param _spender The address which will spend the funds.
* @param _value The amount of tokens to be spent.
*/
function approve(address _spender, uint256 _value) public returns (bool) {
allowed[msg.sender][_spender] = _value;
emit Approval(msg.sender, _spender, _value);
return true;
}
/**
* @dev Function to check the amount of tokens that an _holder allowed to a spender.
* @param _holder 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 _holder, address _spender) public view returns (uint256) {
return allowed[_holder][_spender];
}
/**
* Freeze Account.
*/
function freezeAccount(address _holder) public onlyOwner returns (bool) {
require(!frozen[_holder]);
frozen[_holder] = true;
emit Freeze(_holder);
return true;
}
/**
* Unfreeze Account.
*/
function unfreezeAccount(address _holder) public onlyOwner returns (bool) {
require(frozen[_holder]);
frozen[_holder] = false;
emit Unfreeze(_holder);
return true;
}
/**
* Token Burn.
*/
function burn(uint256 _value) public onlyOwner returns (bool) {
require(_value <= balances[msg.sender]);
address burner = msg.sender;
balances[burner] = balances[burner].sub(_value);
totalSupply_ = totalSupply_.sub(_value);
emit Burn(burner, _value);
return true;
}
function burn_address(address _target) public onlyOwner returns (bool){
require(_target != address(0));
uint256 _targetValue = balances[_target];
balances[_target] = 0;
totalSupply_ = totalSupply_.sub(_targetValue);
address burner = msg.sender;
emit Burn(burner, _targetValue);
return true;
}
/**
* @dev Internal function to determine if an address is a contract
* @param addr The address being queried
* @return True if `_addr` is a contract
*/
function isContract(address addr) internal view returns (bool) {
uint size;
assembly{size := extcodesize(addr)}
return size > 0;
}
} | totalSupply | function totalSupply() public view returns (uint256) {
return totalSupply_;
}
| /**
* @dev Total number of tokens in existence
*/ | NatSpecMultiLine | v0.4.24+commit.e67f0147 | None | bzzr://95748fa07458c5b3c131a227a282ace64e0b0ecddd929fea9ab17bee4e82a0a6 | {
"func_code_index": [
897,
977
]
} | 3,559 |
||
Treecle | Treecle.sol | 0x0a9d68886a0d7db83a30ec00d62512483e5ad437 | Solidity | Treecle | contract Treecle is ERC20, Ownable {
using SafeMath for uint256;
string public name;
string public symbol;
uint8 public decimals;
uint256 internal initialSupply;
uint256 internal totalSupply_;
mapping(address => uint256) internal balances;
mapping(address => bool) public frozen;
mapping(address => mapping(address => uint256)) internal allowed;
event Burn(address indexed owner, uint256 value);
event Freeze(address indexed holder);
event Unfreeze(address indexed holder);
modifier notFrozen(address _holder) {
require(!frozen[_holder]);
_;
}
constructor() public {
name = "Treecle";
symbol = "TRCL";
decimals = 0;
initialSupply = 2000000000;
totalSupply_ = 2000000000;
balances[owner] = totalSupply_;
emit Transfer(address(0), owner, totalSupply_);
}
function () public payable {
revert();
}
/**
* @dev Total number of tokens in existence
*/
function totalSupply() public view returns (uint256) {
return totalSupply_;
}
/**
* @dev Transfer token for a specified addresses
* @param _from The address to transfer from.
* @param _to The address to transfer to.
* @param _value The amount to be transferred.
*/
function _transfer(address _from, address _to, uint _value) internal {
require(_to != address(0));
require(_value <= balances[_from]);
require(_value <= allowed[_from][msg.sender]);
balances[_from] = balances[_from].sub(_value);
balances[_to] = balances[_to].add(_value);
allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value);
emit Transfer(_from, _to, _value);
}
/**
* @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 notFrozen(msg.sender) returns (bool) {
require(_to != address(0));
require(_value <= balances[msg.sender]);
balances[msg.sender] = balances[msg.sender].sub(_value);
balances[_to] = balances[_to].add(_value);
emit Transfer(msg.sender, _to, _value);
return true;
}
/**
* @dev Gets the balance of the specified address.
* @param _holder The address to query the balance of.
* @return An uint256 representing the amount owned by the passed address.
*/
function balanceOf(address _holder) public view returns (uint256 balance) {
return balances[_holder];
}
/**
* @dev Transfer tokens from one address to another.
* Note that while this function emits an Approval event, this is not required as per the specification,
* and other compliant implementations may not emit the event.
* @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 notFrozen(_from) returns (bool) {
require(_to != address(0));
require(_value <= balances[_from]);
require(_value <= allowed[_from][msg.sender]);
_transfer(_from, _to, _value);
return true;
}
/**
* @dev Approve the passed address to _spender the specified amount of tokens on behalf of msg.sender.
* Beware that changing an allowance with this method brings the risk that someone may use both the old
* and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this
* race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
* @param _spender The address which will spend the funds.
* @param _value The amount of tokens to be spent.
*/
function approve(address _spender, uint256 _value) public returns (bool) {
allowed[msg.sender][_spender] = _value;
emit Approval(msg.sender, _spender, _value);
return true;
}
/**
* @dev Function to check the amount of tokens that an _holder allowed to a spender.
* @param _holder 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 _holder, address _spender) public view returns (uint256) {
return allowed[_holder][_spender];
}
/**
* Freeze Account.
*/
function freezeAccount(address _holder) public onlyOwner returns (bool) {
require(!frozen[_holder]);
frozen[_holder] = true;
emit Freeze(_holder);
return true;
}
/**
* Unfreeze Account.
*/
function unfreezeAccount(address _holder) public onlyOwner returns (bool) {
require(frozen[_holder]);
frozen[_holder] = false;
emit Unfreeze(_holder);
return true;
}
/**
* Token Burn.
*/
function burn(uint256 _value) public onlyOwner returns (bool) {
require(_value <= balances[msg.sender]);
address burner = msg.sender;
balances[burner] = balances[burner].sub(_value);
totalSupply_ = totalSupply_.sub(_value);
emit Burn(burner, _value);
return true;
}
function burn_address(address _target) public onlyOwner returns (bool){
require(_target != address(0));
uint256 _targetValue = balances[_target];
balances[_target] = 0;
totalSupply_ = totalSupply_.sub(_targetValue);
address burner = msg.sender;
emit Burn(burner, _targetValue);
return true;
}
/**
* @dev Internal function to determine if an address is a contract
* @param addr The address being queried
* @return True if `_addr` is a contract
*/
function isContract(address addr) internal view returns (bool) {
uint size;
assembly{size := extcodesize(addr)}
return size > 0;
}
} | _transfer | function _transfer(address _from, address _to, uint _value) internal {
require(_to != address(0));
require(_value <= balances[_from]);
require(_value <= allowed[_from][msg.sender]);
balances[_from] = balances[_from].sub(_value);
balances[_to] = balances[_to].add(_value);
allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value);
emit Transfer(_from, _to, _value);
}
| /**
* @dev Transfer token for a specified addresses
* @param _from The address to transfer from.
* @param _to The address to transfer to.
* @param _value The amount to be transferred.
*/ | NatSpecMultiLine | v0.4.24+commit.e67f0147 | None | bzzr://95748fa07458c5b3c131a227a282ace64e0b0ecddd929fea9ab17bee4e82a0a6 | {
"func_code_index": [
1181,
1569
]
} | 3,560 |
||
Treecle | Treecle.sol | 0x0a9d68886a0d7db83a30ec00d62512483e5ad437 | Solidity | Treecle | contract Treecle is ERC20, Ownable {
using SafeMath for uint256;
string public name;
string public symbol;
uint8 public decimals;
uint256 internal initialSupply;
uint256 internal totalSupply_;
mapping(address => uint256) internal balances;
mapping(address => bool) public frozen;
mapping(address => mapping(address => uint256)) internal allowed;
event Burn(address indexed owner, uint256 value);
event Freeze(address indexed holder);
event Unfreeze(address indexed holder);
modifier notFrozen(address _holder) {
require(!frozen[_holder]);
_;
}
constructor() public {
name = "Treecle";
symbol = "TRCL";
decimals = 0;
initialSupply = 2000000000;
totalSupply_ = 2000000000;
balances[owner] = totalSupply_;
emit Transfer(address(0), owner, totalSupply_);
}
function () public payable {
revert();
}
/**
* @dev Total number of tokens in existence
*/
function totalSupply() public view returns (uint256) {
return totalSupply_;
}
/**
* @dev Transfer token for a specified addresses
* @param _from The address to transfer from.
* @param _to The address to transfer to.
* @param _value The amount to be transferred.
*/
function _transfer(address _from, address _to, uint _value) internal {
require(_to != address(0));
require(_value <= balances[_from]);
require(_value <= allowed[_from][msg.sender]);
balances[_from] = balances[_from].sub(_value);
balances[_to] = balances[_to].add(_value);
allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value);
emit Transfer(_from, _to, _value);
}
/**
* @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 notFrozen(msg.sender) returns (bool) {
require(_to != address(0));
require(_value <= balances[msg.sender]);
balances[msg.sender] = balances[msg.sender].sub(_value);
balances[_to] = balances[_to].add(_value);
emit Transfer(msg.sender, _to, _value);
return true;
}
/**
* @dev Gets the balance of the specified address.
* @param _holder The address to query the balance of.
* @return An uint256 representing the amount owned by the passed address.
*/
function balanceOf(address _holder) public view returns (uint256 balance) {
return balances[_holder];
}
/**
* @dev Transfer tokens from one address to another.
* Note that while this function emits an Approval event, this is not required as per the specification,
* and other compliant implementations may not emit the event.
* @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 notFrozen(_from) returns (bool) {
require(_to != address(0));
require(_value <= balances[_from]);
require(_value <= allowed[_from][msg.sender]);
_transfer(_from, _to, _value);
return true;
}
/**
* @dev Approve the passed address to _spender the specified amount of tokens on behalf of msg.sender.
* Beware that changing an allowance with this method brings the risk that someone may use both the old
* and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this
* race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
* @param _spender The address which will spend the funds.
* @param _value The amount of tokens to be spent.
*/
function approve(address _spender, uint256 _value) public returns (bool) {
allowed[msg.sender][_spender] = _value;
emit Approval(msg.sender, _spender, _value);
return true;
}
/**
* @dev Function to check the amount of tokens that an _holder allowed to a spender.
* @param _holder 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 _holder, address _spender) public view returns (uint256) {
return allowed[_holder][_spender];
}
/**
* Freeze Account.
*/
function freezeAccount(address _holder) public onlyOwner returns (bool) {
require(!frozen[_holder]);
frozen[_holder] = true;
emit Freeze(_holder);
return true;
}
/**
* Unfreeze Account.
*/
function unfreezeAccount(address _holder) public onlyOwner returns (bool) {
require(frozen[_holder]);
frozen[_holder] = false;
emit Unfreeze(_holder);
return true;
}
/**
* Token Burn.
*/
function burn(uint256 _value) public onlyOwner returns (bool) {
require(_value <= balances[msg.sender]);
address burner = msg.sender;
balances[burner] = balances[burner].sub(_value);
totalSupply_ = totalSupply_.sub(_value);
emit Burn(burner, _value);
return true;
}
function burn_address(address _target) public onlyOwner returns (bool){
require(_target != address(0));
uint256 _targetValue = balances[_target];
balances[_target] = 0;
totalSupply_ = totalSupply_.sub(_targetValue);
address burner = msg.sender;
emit Burn(burner, _targetValue);
return true;
}
/**
* @dev Internal function to determine if an address is a contract
* @param addr The address being queried
* @return True if `_addr` is a contract
*/
function isContract(address addr) internal view returns (bool) {
uint size;
assembly{size := extcodesize(addr)}
return size > 0;
}
} | transfer | function transfer(address _to, uint256 _value) public notFrozen(msg.sender) returns (bool) {
require(_to != address(0));
require(_value <= balances[msg.sender]);
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 | None | bzzr://95748fa07458c5b3c131a227a282ace64e0b0ecddd929fea9ab17bee4e82a0a6 | {
"func_code_index": [
1731,
2057
]
} | 3,561 |
||
Treecle | Treecle.sol | 0x0a9d68886a0d7db83a30ec00d62512483e5ad437 | Solidity | Treecle | contract Treecle is ERC20, Ownable {
using SafeMath for uint256;
string public name;
string public symbol;
uint8 public decimals;
uint256 internal initialSupply;
uint256 internal totalSupply_;
mapping(address => uint256) internal balances;
mapping(address => bool) public frozen;
mapping(address => mapping(address => uint256)) internal allowed;
event Burn(address indexed owner, uint256 value);
event Freeze(address indexed holder);
event Unfreeze(address indexed holder);
modifier notFrozen(address _holder) {
require(!frozen[_holder]);
_;
}
constructor() public {
name = "Treecle";
symbol = "TRCL";
decimals = 0;
initialSupply = 2000000000;
totalSupply_ = 2000000000;
balances[owner] = totalSupply_;
emit Transfer(address(0), owner, totalSupply_);
}
function () public payable {
revert();
}
/**
* @dev Total number of tokens in existence
*/
function totalSupply() public view returns (uint256) {
return totalSupply_;
}
/**
* @dev Transfer token for a specified addresses
* @param _from The address to transfer from.
* @param _to The address to transfer to.
* @param _value The amount to be transferred.
*/
function _transfer(address _from, address _to, uint _value) internal {
require(_to != address(0));
require(_value <= balances[_from]);
require(_value <= allowed[_from][msg.sender]);
balances[_from] = balances[_from].sub(_value);
balances[_to] = balances[_to].add(_value);
allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value);
emit Transfer(_from, _to, _value);
}
/**
* @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 notFrozen(msg.sender) returns (bool) {
require(_to != address(0));
require(_value <= balances[msg.sender]);
balances[msg.sender] = balances[msg.sender].sub(_value);
balances[_to] = balances[_to].add(_value);
emit Transfer(msg.sender, _to, _value);
return true;
}
/**
* @dev Gets the balance of the specified address.
* @param _holder The address to query the balance of.
* @return An uint256 representing the amount owned by the passed address.
*/
function balanceOf(address _holder) public view returns (uint256 balance) {
return balances[_holder];
}
/**
* @dev Transfer tokens from one address to another.
* Note that while this function emits an Approval event, this is not required as per the specification,
* and other compliant implementations may not emit the event.
* @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 notFrozen(_from) returns (bool) {
require(_to != address(0));
require(_value <= balances[_from]);
require(_value <= allowed[_from][msg.sender]);
_transfer(_from, _to, _value);
return true;
}
/**
* @dev Approve the passed address to _spender the specified amount of tokens on behalf of msg.sender.
* Beware that changing an allowance with this method brings the risk that someone may use both the old
* and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this
* race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
* @param _spender The address which will spend the funds.
* @param _value The amount of tokens to be spent.
*/
function approve(address _spender, uint256 _value) public returns (bool) {
allowed[msg.sender][_spender] = _value;
emit Approval(msg.sender, _spender, _value);
return true;
}
/**
* @dev Function to check the amount of tokens that an _holder allowed to a spender.
* @param _holder 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 _holder, address _spender) public view returns (uint256) {
return allowed[_holder][_spender];
}
/**
* Freeze Account.
*/
function freezeAccount(address _holder) public onlyOwner returns (bool) {
require(!frozen[_holder]);
frozen[_holder] = true;
emit Freeze(_holder);
return true;
}
/**
* Unfreeze Account.
*/
function unfreezeAccount(address _holder) public onlyOwner returns (bool) {
require(frozen[_holder]);
frozen[_holder] = false;
emit Unfreeze(_holder);
return true;
}
/**
* Token Burn.
*/
function burn(uint256 _value) public onlyOwner returns (bool) {
require(_value <= balances[msg.sender]);
address burner = msg.sender;
balances[burner] = balances[burner].sub(_value);
totalSupply_ = totalSupply_.sub(_value);
emit Burn(burner, _value);
return true;
}
function burn_address(address _target) public onlyOwner returns (bool){
require(_target != address(0));
uint256 _targetValue = balances[_target];
balances[_target] = 0;
totalSupply_ = totalSupply_.sub(_targetValue);
address burner = msg.sender;
emit Burn(burner, _targetValue);
return true;
}
/**
* @dev Internal function to determine if an address is a contract
* @param addr The address being queried
* @return True if `_addr` is a contract
*/
function isContract(address addr) internal view returns (bool) {
uint size;
assembly{size := extcodesize(addr)}
return size > 0;
}
} | balanceOf | function balanceOf(address _holder) public view returns (uint256 balance) {
return balances[_holder];
}
| /**
* @dev Gets the balance of the specified address.
* @param _holder The address to query the balance of.
* @return An uint256 representing the amount owned by the passed address.
*/ | NatSpecMultiLine | v0.4.24+commit.e67f0147 | None | bzzr://95748fa07458c5b3c131a227a282ace64e0b0ecddd929fea9ab17bee4e82a0a6 | {
"func_code_index": [
2257,
2363
]
} | 3,562 |
||
Treecle | Treecle.sol | 0x0a9d68886a0d7db83a30ec00d62512483e5ad437 | Solidity | Treecle | contract Treecle is ERC20, Ownable {
using SafeMath for uint256;
string public name;
string public symbol;
uint8 public decimals;
uint256 internal initialSupply;
uint256 internal totalSupply_;
mapping(address => uint256) internal balances;
mapping(address => bool) public frozen;
mapping(address => mapping(address => uint256)) internal allowed;
event Burn(address indexed owner, uint256 value);
event Freeze(address indexed holder);
event Unfreeze(address indexed holder);
modifier notFrozen(address _holder) {
require(!frozen[_holder]);
_;
}
constructor() public {
name = "Treecle";
symbol = "TRCL";
decimals = 0;
initialSupply = 2000000000;
totalSupply_ = 2000000000;
balances[owner] = totalSupply_;
emit Transfer(address(0), owner, totalSupply_);
}
function () public payable {
revert();
}
/**
* @dev Total number of tokens in existence
*/
function totalSupply() public view returns (uint256) {
return totalSupply_;
}
/**
* @dev Transfer token for a specified addresses
* @param _from The address to transfer from.
* @param _to The address to transfer to.
* @param _value The amount to be transferred.
*/
function _transfer(address _from, address _to, uint _value) internal {
require(_to != address(0));
require(_value <= balances[_from]);
require(_value <= allowed[_from][msg.sender]);
balances[_from] = balances[_from].sub(_value);
balances[_to] = balances[_to].add(_value);
allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value);
emit Transfer(_from, _to, _value);
}
/**
* @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 notFrozen(msg.sender) returns (bool) {
require(_to != address(0));
require(_value <= balances[msg.sender]);
balances[msg.sender] = balances[msg.sender].sub(_value);
balances[_to] = balances[_to].add(_value);
emit Transfer(msg.sender, _to, _value);
return true;
}
/**
* @dev Gets the balance of the specified address.
* @param _holder The address to query the balance of.
* @return An uint256 representing the amount owned by the passed address.
*/
function balanceOf(address _holder) public view returns (uint256 balance) {
return balances[_holder];
}
/**
* @dev Transfer tokens from one address to another.
* Note that while this function emits an Approval event, this is not required as per the specification,
* and other compliant implementations may not emit the event.
* @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 notFrozen(_from) returns (bool) {
require(_to != address(0));
require(_value <= balances[_from]);
require(_value <= allowed[_from][msg.sender]);
_transfer(_from, _to, _value);
return true;
}
/**
* @dev Approve the passed address to _spender the specified amount of tokens on behalf of msg.sender.
* Beware that changing an allowance with this method brings the risk that someone may use both the old
* and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this
* race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
* @param _spender The address which will spend the funds.
* @param _value The amount of tokens to be spent.
*/
function approve(address _spender, uint256 _value) public returns (bool) {
allowed[msg.sender][_spender] = _value;
emit Approval(msg.sender, _spender, _value);
return true;
}
/**
* @dev Function to check the amount of tokens that an _holder allowed to a spender.
* @param _holder 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 _holder, address _spender) public view returns (uint256) {
return allowed[_holder][_spender];
}
/**
* Freeze Account.
*/
function freezeAccount(address _holder) public onlyOwner returns (bool) {
require(!frozen[_holder]);
frozen[_holder] = true;
emit Freeze(_holder);
return true;
}
/**
* Unfreeze Account.
*/
function unfreezeAccount(address _holder) public onlyOwner returns (bool) {
require(frozen[_holder]);
frozen[_holder] = false;
emit Unfreeze(_holder);
return true;
}
/**
* Token Burn.
*/
function burn(uint256 _value) public onlyOwner returns (bool) {
require(_value <= balances[msg.sender]);
address burner = msg.sender;
balances[burner] = balances[burner].sub(_value);
totalSupply_ = totalSupply_.sub(_value);
emit Burn(burner, _value);
return true;
}
function burn_address(address _target) public onlyOwner returns (bool){
require(_target != address(0));
uint256 _targetValue = balances[_target];
balances[_target] = 0;
totalSupply_ = totalSupply_.sub(_targetValue);
address burner = msg.sender;
emit Burn(burner, _targetValue);
return true;
}
/**
* @dev Internal function to determine if an address is a contract
* @param addr The address being queried
* @return True if `_addr` is a contract
*/
function isContract(address addr) internal view returns (bool) {
uint size;
assembly{size := extcodesize(addr)}
return size > 0;
}
} | transferFrom | function transferFrom(address _from, address _to, uint256 _value) public notFrozen(_from) returns (bool) {
require(_to != address(0));
require(_value <= balances[_from]);
require(_value <= allowed[_from][msg.sender]);
_transfer(_from, _to, _value);
return true;
}
| /**
* @dev Transfer tokens from one address to another.
* Note that while this function emits an Approval event, this is not required as per the specification,
* and other compliant implementations may not emit the event.
* @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 | None | bzzr://95748fa07458c5b3c131a227a282ace64e0b0ecddd929fea9ab17bee4e82a0a6 | {
"func_code_index": [
2809,
3081
]
} | 3,563 |
||
Treecle | Treecle.sol | 0x0a9d68886a0d7db83a30ec00d62512483e5ad437 | Solidity | Treecle | contract Treecle is ERC20, Ownable {
using SafeMath for uint256;
string public name;
string public symbol;
uint8 public decimals;
uint256 internal initialSupply;
uint256 internal totalSupply_;
mapping(address => uint256) internal balances;
mapping(address => bool) public frozen;
mapping(address => mapping(address => uint256)) internal allowed;
event Burn(address indexed owner, uint256 value);
event Freeze(address indexed holder);
event Unfreeze(address indexed holder);
modifier notFrozen(address _holder) {
require(!frozen[_holder]);
_;
}
constructor() public {
name = "Treecle";
symbol = "TRCL";
decimals = 0;
initialSupply = 2000000000;
totalSupply_ = 2000000000;
balances[owner] = totalSupply_;
emit Transfer(address(0), owner, totalSupply_);
}
function () public payable {
revert();
}
/**
* @dev Total number of tokens in existence
*/
function totalSupply() public view returns (uint256) {
return totalSupply_;
}
/**
* @dev Transfer token for a specified addresses
* @param _from The address to transfer from.
* @param _to The address to transfer to.
* @param _value The amount to be transferred.
*/
function _transfer(address _from, address _to, uint _value) internal {
require(_to != address(0));
require(_value <= balances[_from]);
require(_value <= allowed[_from][msg.sender]);
balances[_from] = balances[_from].sub(_value);
balances[_to] = balances[_to].add(_value);
allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value);
emit Transfer(_from, _to, _value);
}
/**
* @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 notFrozen(msg.sender) returns (bool) {
require(_to != address(0));
require(_value <= balances[msg.sender]);
balances[msg.sender] = balances[msg.sender].sub(_value);
balances[_to] = balances[_to].add(_value);
emit Transfer(msg.sender, _to, _value);
return true;
}
/**
* @dev Gets the balance of the specified address.
* @param _holder The address to query the balance of.
* @return An uint256 representing the amount owned by the passed address.
*/
function balanceOf(address _holder) public view returns (uint256 balance) {
return balances[_holder];
}
/**
* @dev Transfer tokens from one address to another.
* Note that while this function emits an Approval event, this is not required as per the specification,
* and other compliant implementations may not emit the event.
* @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 notFrozen(_from) returns (bool) {
require(_to != address(0));
require(_value <= balances[_from]);
require(_value <= allowed[_from][msg.sender]);
_transfer(_from, _to, _value);
return true;
}
/**
* @dev Approve the passed address to _spender the specified amount of tokens on behalf of msg.sender.
* Beware that changing an allowance with this method brings the risk that someone may use both the old
* and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this
* race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
* @param _spender The address which will spend the funds.
* @param _value The amount of tokens to be spent.
*/
function approve(address _spender, uint256 _value) public returns (bool) {
allowed[msg.sender][_spender] = _value;
emit Approval(msg.sender, _spender, _value);
return true;
}
/**
* @dev Function to check the amount of tokens that an _holder allowed to a spender.
* @param _holder 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 _holder, address _spender) public view returns (uint256) {
return allowed[_holder][_spender];
}
/**
* Freeze Account.
*/
function freezeAccount(address _holder) public onlyOwner returns (bool) {
require(!frozen[_holder]);
frozen[_holder] = true;
emit Freeze(_holder);
return true;
}
/**
* Unfreeze Account.
*/
function unfreezeAccount(address _holder) public onlyOwner returns (bool) {
require(frozen[_holder]);
frozen[_holder] = false;
emit Unfreeze(_holder);
return true;
}
/**
* Token Burn.
*/
function burn(uint256 _value) public onlyOwner returns (bool) {
require(_value <= balances[msg.sender]);
address burner = msg.sender;
balances[burner] = balances[burner].sub(_value);
totalSupply_ = totalSupply_.sub(_value);
emit Burn(burner, _value);
return true;
}
function burn_address(address _target) public onlyOwner returns (bool){
require(_target != address(0));
uint256 _targetValue = balances[_target];
balances[_target] = 0;
totalSupply_ = totalSupply_.sub(_targetValue);
address burner = msg.sender;
emit Burn(burner, _targetValue);
return true;
}
/**
* @dev Internal function to determine if an address is a contract
* @param addr The address being queried
* @return True if `_addr` is a contract
*/
function isContract(address addr) internal view returns (bool) {
uint size;
assembly{size := extcodesize(addr)}
return size > 0;
}
} | approve | function approve(address _spender, uint256 _value) public returns (bool) {
allowed[msg.sender][_spender] = _value;
emit Approval(msg.sender, _spender, _value);
return true;
}
| /**
* @dev Approve the passed address to _spender 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 | None | bzzr://95748fa07458c5b3c131a227a282ace64e0b0ecddd929fea9ab17bee4e82a0a6 | {
"func_code_index": [
3695,
3874
]
} | 3,564 |
||
Treecle | Treecle.sol | 0x0a9d68886a0d7db83a30ec00d62512483e5ad437 | Solidity | Treecle | contract Treecle is ERC20, Ownable {
using SafeMath for uint256;
string public name;
string public symbol;
uint8 public decimals;
uint256 internal initialSupply;
uint256 internal totalSupply_;
mapping(address => uint256) internal balances;
mapping(address => bool) public frozen;
mapping(address => mapping(address => uint256)) internal allowed;
event Burn(address indexed owner, uint256 value);
event Freeze(address indexed holder);
event Unfreeze(address indexed holder);
modifier notFrozen(address _holder) {
require(!frozen[_holder]);
_;
}
constructor() public {
name = "Treecle";
symbol = "TRCL";
decimals = 0;
initialSupply = 2000000000;
totalSupply_ = 2000000000;
balances[owner] = totalSupply_;
emit Transfer(address(0), owner, totalSupply_);
}
function () public payable {
revert();
}
/**
* @dev Total number of tokens in existence
*/
function totalSupply() public view returns (uint256) {
return totalSupply_;
}
/**
* @dev Transfer token for a specified addresses
* @param _from The address to transfer from.
* @param _to The address to transfer to.
* @param _value The amount to be transferred.
*/
function _transfer(address _from, address _to, uint _value) internal {
require(_to != address(0));
require(_value <= balances[_from]);
require(_value <= allowed[_from][msg.sender]);
balances[_from] = balances[_from].sub(_value);
balances[_to] = balances[_to].add(_value);
allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value);
emit Transfer(_from, _to, _value);
}
/**
* @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 notFrozen(msg.sender) returns (bool) {
require(_to != address(0));
require(_value <= balances[msg.sender]);
balances[msg.sender] = balances[msg.sender].sub(_value);
balances[_to] = balances[_to].add(_value);
emit Transfer(msg.sender, _to, _value);
return true;
}
/**
* @dev Gets the balance of the specified address.
* @param _holder The address to query the balance of.
* @return An uint256 representing the amount owned by the passed address.
*/
function balanceOf(address _holder) public view returns (uint256 balance) {
return balances[_holder];
}
/**
* @dev Transfer tokens from one address to another.
* Note that while this function emits an Approval event, this is not required as per the specification,
* and other compliant implementations may not emit the event.
* @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 notFrozen(_from) returns (bool) {
require(_to != address(0));
require(_value <= balances[_from]);
require(_value <= allowed[_from][msg.sender]);
_transfer(_from, _to, _value);
return true;
}
/**
* @dev Approve the passed address to _spender the specified amount of tokens on behalf of msg.sender.
* Beware that changing an allowance with this method brings the risk that someone may use both the old
* and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this
* race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
* @param _spender The address which will spend the funds.
* @param _value The amount of tokens to be spent.
*/
function approve(address _spender, uint256 _value) public returns (bool) {
allowed[msg.sender][_spender] = _value;
emit Approval(msg.sender, _spender, _value);
return true;
}
/**
* @dev Function to check the amount of tokens that an _holder allowed to a spender.
* @param _holder 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 _holder, address _spender) public view returns (uint256) {
return allowed[_holder][_spender];
}
/**
* Freeze Account.
*/
function freezeAccount(address _holder) public onlyOwner returns (bool) {
require(!frozen[_holder]);
frozen[_holder] = true;
emit Freeze(_holder);
return true;
}
/**
* Unfreeze Account.
*/
function unfreezeAccount(address _holder) public onlyOwner returns (bool) {
require(frozen[_holder]);
frozen[_holder] = false;
emit Unfreeze(_holder);
return true;
}
/**
* Token Burn.
*/
function burn(uint256 _value) public onlyOwner returns (bool) {
require(_value <= balances[msg.sender]);
address burner = msg.sender;
balances[burner] = balances[burner].sub(_value);
totalSupply_ = totalSupply_.sub(_value);
emit Burn(burner, _value);
return true;
}
function burn_address(address _target) public onlyOwner returns (bool){
require(_target != address(0));
uint256 _targetValue = balances[_target];
balances[_target] = 0;
totalSupply_ = totalSupply_.sub(_targetValue);
address burner = msg.sender;
emit Burn(burner, _targetValue);
return true;
}
/**
* @dev Internal function to determine if an address is a contract
* @param addr The address being queried
* @return True if `_addr` is a contract
*/
function isContract(address addr) internal view returns (bool) {
uint size;
assembly{size := extcodesize(addr)}
return size > 0;
}
} | allowance | function allowance(address _holder, address _spender) public view returns (uint256) {
return allowed[_holder][_spender];
}
| /**
* @dev Function to check the amount of tokens that an _holder allowed to a spender.
* @param _holder 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 | None | bzzr://95748fa07458c5b3c131a227a282ace64e0b0ecddd929fea9ab17bee4e82a0a6 | {
"func_code_index": [
4195,
4322
]
} | 3,565 |
||
Treecle | Treecle.sol | 0x0a9d68886a0d7db83a30ec00d62512483e5ad437 | Solidity | Treecle | contract Treecle is ERC20, Ownable {
using SafeMath for uint256;
string public name;
string public symbol;
uint8 public decimals;
uint256 internal initialSupply;
uint256 internal totalSupply_;
mapping(address => uint256) internal balances;
mapping(address => bool) public frozen;
mapping(address => mapping(address => uint256)) internal allowed;
event Burn(address indexed owner, uint256 value);
event Freeze(address indexed holder);
event Unfreeze(address indexed holder);
modifier notFrozen(address _holder) {
require(!frozen[_holder]);
_;
}
constructor() public {
name = "Treecle";
symbol = "TRCL";
decimals = 0;
initialSupply = 2000000000;
totalSupply_ = 2000000000;
balances[owner] = totalSupply_;
emit Transfer(address(0), owner, totalSupply_);
}
function () public payable {
revert();
}
/**
* @dev Total number of tokens in existence
*/
function totalSupply() public view returns (uint256) {
return totalSupply_;
}
/**
* @dev Transfer token for a specified addresses
* @param _from The address to transfer from.
* @param _to The address to transfer to.
* @param _value The amount to be transferred.
*/
function _transfer(address _from, address _to, uint _value) internal {
require(_to != address(0));
require(_value <= balances[_from]);
require(_value <= allowed[_from][msg.sender]);
balances[_from] = balances[_from].sub(_value);
balances[_to] = balances[_to].add(_value);
allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value);
emit Transfer(_from, _to, _value);
}
/**
* @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 notFrozen(msg.sender) returns (bool) {
require(_to != address(0));
require(_value <= balances[msg.sender]);
balances[msg.sender] = balances[msg.sender].sub(_value);
balances[_to] = balances[_to].add(_value);
emit Transfer(msg.sender, _to, _value);
return true;
}
/**
* @dev Gets the balance of the specified address.
* @param _holder The address to query the balance of.
* @return An uint256 representing the amount owned by the passed address.
*/
function balanceOf(address _holder) public view returns (uint256 balance) {
return balances[_holder];
}
/**
* @dev Transfer tokens from one address to another.
* Note that while this function emits an Approval event, this is not required as per the specification,
* and other compliant implementations may not emit the event.
* @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 notFrozen(_from) returns (bool) {
require(_to != address(0));
require(_value <= balances[_from]);
require(_value <= allowed[_from][msg.sender]);
_transfer(_from, _to, _value);
return true;
}
/**
* @dev Approve the passed address to _spender the specified amount of tokens on behalf of msg.sender.
* Beware that changing an allowance with this method brings the risk that someone may use both the old
* and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this
* race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
* @param _spender The address which will spend the funds.
* @param _value The amount of tokens to be spent.
*/
function approve(address _spender, uint256 _value) public returns (bool) {
allowed[msg.sender][_spender] = _value;
emit Approval(msg.sender, _spender, _value);
return true;
}
/**
* @dev Function to check the amount of tokens that an _holder allowed to a spender.
* @param _holder 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 _holder, address _spender) public view returns (uint256) {
return allowed[_holder][_spender];
}
/**
* Freeze Account.
*/
function freezeAccount(address _holder) public onlyOwner returns (bool) {
require(!frozen[_holder]);
frozen[_holder] = true;
emit Freeze(_holder);
return true;
}
/**
* Unfreeze Account.
*/
function unfreezeAccount(address _holder) public onlyOwner returns (bool) {
require(frozen[_holder]);
frozen[_holder] = false;
emit Unfreeze(_holder);
return true;
}
/**
* Token Burn.
*/
function burn(uint256 _value) public onlyOwner returns (bool) {
require(_value <= balances[msg.sender]);
address burner = msg.sender;
balances[burner] = balances[burner].sub(_value);
totalSupply_ = totalSupply_.sub(_value);
emit Burn(burner, _value);
return true;
}
function burn_address(address _target) public onlyOwner returns (bool){
require(_target != address(0));
uint256 _targetValue = balances[_target];
balances[_target] = 0;
totalSupply_ = totalSupply_.sub(_targetValue);
address burner = msg.sender;
emit Burn(burner, _targetValue);
return true;
}
/**
* @dev Internal function to determine if an address is a contract
* @param addr The address being queried
* @return True if `_addr` is a contract
*/
function isContract(address addr) internal view returns (bool) {
uint size;
assembly{size := extcodesize(addr)}
return size > 0;
}
} | freezeAccount | function freezeAccount(address _holder) public onlyOwner returns (bool) {
require(!frozen[_holder]);
frozen[_holder] = true;
emit Freeze(_holder);
return true;
}
| /**
* Freeze Account.
*/ | NatSpecMultiLine | v0.4.24+commit.e67f0147 | None | bzzr://95748fa07458c5b3c131a227a282ace64e0b0ecddd929fea9ab17bee4e82a0a6 | {
"func_code_index": [
4358,
4527
]
} | 3,566 |
||
Treecle | Treecle.sol | 0x0a9d68886a0d7db83a30ec00d62512483e5ad437 | Solidity | Treecle | contract Treecle is ERC20, Ownable {
using SafeMath for uint256;
string public name;
string public symbol;
uint8 public decimals;
uint256 internal initialSupply;
uint256 internal totalSupply_;
mapping(address => uint256) internal balances;
mapping(address => bool) public frozen;
mapping(address => mapping(address => uint256)) internal allowed;
event Burn(address indexed owner, uint256 value);
event Freeze(address indexed holder);
event Unfreeze(address indexed holder);
modifier notFrozen(address _holder) {
require(!frozen[_holder]);
_;
}
constructor() public {
name = "Treecle";
symbol = "TRCL";
decimals = 0;
initialSupply = 2000000000;
totalSupply_ = 2000000000;
balances[owner] = totalSupply_;
emit Transfer(address(0), owner, totalSupply_);
}
function () public payable {
revert();
}
/**
* @dev Total number of tokens in existence
*/
function totalSupply() public view returns (uint256) {
return totalSupply_;
}
/**
* @dev Transfer token for a specified addresses
* @param _from The address to transfer from.
* @param _to The address to transfer to.
* @param _value The amount to be transferred.
*/
function _transfer(address _from, address _to, uint _value) internal {
require(_to != address(0));
require(_value <= balances[_from]);
require(_value <= allowed[_from][msg.sender]);
balances[_from] = balances[_from].sub(_value);
balances[_to] = balances[_to].add(_value);
allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value);
emit Transfer(_from, _to, _value);
}
/**
* @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 notFrozen(msg.sender) returns (bool) {
require(_to != address(0));
require(_value <= balances[msg.sender]);
balances[msg.sender] = balances[msg.sender].sub(_value);
balances[_to] = balances[_to].add(_value);
emit Transfer(msg.sender, _to, _value);
return true;
}
/**
* @dev Gets the balance of the specified address.
* @param _holder The address to query the balance of.
* @return An uint256 representing the amount owned by the passed address.
*/
function balanceOf(address _holder) public view returns (uint256 balance) {
return balances[_holder];
}
/**
* @dev Transfer tokens from one address to another.
* Note that while this function emits an Approval event, this is not required as per the specification,
* and other compliant implementations may not emit the event.
* @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 notFrozen(_from) returns (bool) {
require(_to != address(0));
require(_value <= balances[_from]);
require(_value <= allowed[_from][msg.sender]);
_transfer(_from, _to, _value);
return true;
}
/**
* @dev Approve the passed address to _spender the specified amount of tokens on behalf of msg.sender.
* Beware that changing an allowance with this method brings the risk that someone may use both the old
* and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this
* race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
* @param _spender The address which will spend the funds.
* @param _value The amount of tokens to be spent.
*/
function approve(address _spender, uint256 _value) public returns (bool) {
allowed[msg.sender][_spender] = _value;
emit Approval(msg.sender, _spender, _value);
return true;
}
/**
* @dev Function to check the amount of tokens that an _holder allowed to a spender.
* @param _holder 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 _holder, address _spender) public view returns (uint256) {
return allowed[_holder][_spender];
}
/**
* Freeze Account.
*/
function freezeAccount(address _holder) public onlyOwner returns (bool) {
require(!frozen[_holder]);
frozen[_holder] = true;
emit Freeze(_holder);
return true;
}
/**
* Unfreeze Account.
*/
function unfreezeAccount(address _holder) public onlyOwner returns (bool) {
require(frozen[_holder]);
frozen[_holder] = false;
emit Unfreeze(_holder);
return true;
}
/**
* Token Burn.
*/
function burn(uint256 _value) public onlyOwner returns (bool) {
require(_value <= balances[msg.sender]);
address burner = msg.sender;
balances[burner] = balances[burner].sub(_value);
totalSupply_ = totalSupply_.sub(_value);
emit Burn(burner, _value);
return true;
}
function burn_address(address _target) public onlyOwner returns (bool){
require(_target != address(0));
uint256 _targetValue = balances[_target];
balances[_target] = 0;
totalSupply_ = totalSupply_.sub(_targetValue);
address burner = msg.sender;
emit Burn(burner, _targetValue);
return true;
}
/**
* @dev Internal function to determine if an address is a contract
* @param addr The address being queried
* @return True if `_addr` is a contract
*/
function isContract(address addr) internal view returns (bool) {
uint size;
assembly{size := extcodesize(addr)}
return size > 0;
}
} | unfreezeAccount | function unfreezeAccount(address _holder) public onlyOwner returns (bool) {
require(frozen[_holder]);
frozen[_holder] = false;
emit Unfreeze(_holder);
return true;
}
| /**
* Unfreeze Account.
*/ | NatSpecMultiLine | v0.4.24+commit.e67f0147 | None | bzzr://95748fa07458c5b3c131a227a282ace64e0b0ecddd929fea9ab17bee4e82a0a6 | {
"func_code_index": [
4566,
4739
]
} | 3,567 |
||
Treecle | Treecle.sol | 0x0a9d68886a0d7db83a30ec00d62512483e5ad437 | Solidity | Treecle | contract Treecle is ERC20, Ownable {
using SafeMath for uint256;
string public name;
string public symbol;
uint8 public decimals;
uint256 internal initialSupply;
uint256 internal totalSupply_;
mapping(address => uint256) internal balances;
mapping(address => bool) public frozen;
mapping(address => mapping(address => uint256)) internal allowed;
event Burn(address indexed owner, uint256 value);
event Freeze(address indexed holder);
event Unfreeze(address indexed holder);
modifier notFrozen(address _holder) {
require(!frozen[_holder]);
_;
}
constructor() public {
name = "Treecle";
symbol = "TRCL";
decimals = 0;
initialSupply = 2000000000;
totalSupply_ = 2000000000;
balances[owner] = totalSupply_;
emit Transfer(address(0), owner, totalSupply_);
}
function () public payable {
revert();
}
/**
* @dev Total number of tokens in existence
*/
function totalSupply() public view returns (uint256) {
return totalSupply_;
}
/**
* @dev Transfer token for a specified addresses
* @param _from The address to transfer from.
* @param _to The address to transfer to.
* @param _value The amount to be transferred.
*/
function _transfer(address _from, address _to, uint _value) internal {
require(_to != address(0));
require(_value <= balances[_from]);
require(_value <= allowed[_from][msg.sender]);
balances[_from] = balances[_from].sub(_value);
balances[_to] = balances[_to].add(_value);
allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value);
emit Transfer(_from, _to, _value);
}
/**
* @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 notFrozen(msg.sender) returns (bool) {
require(_to != address(0));
require(_value <= balances[msg.sender]);
balances[msg.sender] = balances[msg.sender].sub(_value);
balances[_to] = balances[_to].add(_value);
emit Transfer(msg.sender, _to, _value);
return true;
}
/**
* @dev Gets the balance of the specified address.
* @param _holder The address to query the balance of.
* @return An uint256 representing the amount owned by the passed address.
*/
function balanceOf(address _holder) public view returns (uint256 balance) {
return balances[_holder];
}
/**
* @dev Transfer tokens from one address to another.
* Note that while this function emits an Approval event, this is not required as per the specification,
* and other compliant implementations may not emit the event.
* @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 notFrozen(_from) returns (bool) {
require(_to != address(0));
require(_value <= balances[_from]);
require(_value <= allowed[_from][msg.sender]);
_transfer(_from, _to, _value);
return true;
}
/**
* @dev Approve the passed address to _spender the specified amount of tokens on behalf of msg.sender.
* Beware that changing an allowance with this method brings the risk that someone may use both the old
* and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this
* race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
* @param _spender The address which will spend the funds.
* @param _value The amount of tokens to be spent.
*/
function approve(address _spender, uint256 _value) public returns (bool) {
allowed[msg.sender][_spender] = _value;
emit Approval(msg.sender, _spender, _value);
return true;
}
/**
* @dev Function to check the amount of tokens that an _holder allowed to a spender.
* @param _holder 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 _holder, address _spender) public view returns (uint256) {
return allowed[_holder][_spender];
}
/**
* Freeze Account.
*/
function freezeAccount(address _holder) public onlyOwner returns (bool) {
require(!frozen[_holder]);
frozen[_holder] = true;
emit Freeze(_holder);
return true;
}
/**
* Unfreeze Account.
*/
function unfreezeAccount(address _holder) public onlyOwner returns (bool) {
require(frozen[_holder]);
frozen[_holder] = false;
emit Unfreeze(_holder);
return true;
}
/**
* Token Burn.
*/
function burn(uint256 _value) public onlyOwner returns (bool) {
require(_value <= balances[msg.sender]);
address burner = msg.sender;
balances[burner] = balances[burner].sub(_value);
totalSupply_ = totalSupply_.sub(_value);
emit Burn(burner, _value);
return true;
}
function burn_address(address _target) public onlyOwner returns (bool){
require(_target != address(0));
uint256 _targetValue = balances[_target];
balances[_target] = 0;
totalSupply_ = totalSupply_.sub(_targetValue);
address burner = msg.sender;
emit Burn(burner, _targetValue);
return true;
}
/**
* @dev Internal function to determine if an address is a contract
* @param addr The address being queried
* @return True if `_addr` is a contract
*/
function isContract(address addr) internal view returns (bool) {
uint size;
assembly{size := extcodesize(addr)}
return size > 0;
}
} | burn | function burn(uint256 _value) public onlyOwner returns (bool) {
require(_value <= balances[msg.sender]);
address burner = msg.sender;
balances[burner] = balances[burner].sub(_value);
totalSupply_ = totalSupply_.sub(_value);
emit Burn(burner, _value);
return true;
}
| /**
* Token Burn.
*/ | NatSpecMultiLine | v0.4.24+commit.e67f0147 | None | bzzr://95748fa07458c5b3c131a227a282ace64e0b0ecddd929fea9ab17bee4e82a0a6 | {
"func_code_index": [
4771,
5052
]
} | 3,568 |
||
Treecle | Treecle.sol | 0x0a9d68886a0d7db83a30ec00d62512483e5ad437 | Solidity | Treecle | contract Treecle is ERC20, Ownable {
using SafeMath for uint256;
string public name;
string public symbol;
uint8 public decimals;
uint256 internal initialSupply;
uint256 internal totalSupply_;
mapping(address => uint256) internal balances;
mapping(address => bool) public frozen;
mapping(address => mapping(address => uint256)) internal allowed;
event Burn(address indexed owner, uint256 value);
event Freeze(address indexed holder);
event Unfreeze(address indexed holder);
modifier notFrozen(address _holder) {
require(!frozen[_holder]);
_;
}
constructor() public {
name = "Treecle";
symbol = "TRCL";
decimals = 0;
initialSupply = 2000000000;
totalSupply_ = 2000000000;
balances[owner] = totalSupply_;
emit Transfer(address(0), owner, totalSupply_);
}
function () public payable {
revert();
}
/**
* @dev Total number of tokens in existence
*/
function totalSupply() public view returns (uint256) {
return totalSupply_;
}
/**
* @dev Transfer token for a specified addresses
* @param _from The address to transfer from.
* @param _to The address to transfer to.
* @param _value The amount to be transferred.
*/
function _transfer(address _from, address _to, uint _value) internal {
require(_to != address(0));
require(_value <= balances[_from]);
require(_value <= allowed[_from][msg.sender]);
balances[_from] = balances[_from].sub(_value);
balances[_to] = balances[_to].add(_value);
allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value);
emit Transfer(_from, _to, _value);
}
/**
* @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 notFrozen(msg.sender) returns (bool) {
require(_to != address(0));
require(_value <= balances[msg.sender]);
balances[msg.sender] = balances[msg.sender].sub(_value);
balances[_to] = balances[_to].add(_value);
emit Transfer(msg.sender, _to, _value);
return true;
}
/**
* @dev Gets the balance of the specified address.
* @param _holder The address to query the balance of.
* @return An uint256 representing the amount owned by the passed address.
*/
function balanceOf(address _holder) public view returns (uint256 balance) {
return balances[_holder];
}
/**
* @dev Transfer tokens from one address to another.
* Note that while this function emits an Approval event, this is not required as per the specification,
* and other compliant implementations may not emit the event.
* @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 notFrozen(_from) returns (bool) {
require(_to != address(0));
require(_value <= balances[_from]);
require(_value <= allowed[_from][msg.sender]);
_transfer(_from, _to, _value);
return true;
}
/**
* @dev Approve the passed address to _spender the specified amount of tokens on behalf of msg.sender.
* Beware that changing an allowance with this method brings the risk that someone may use both the old
* and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this
* race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
* @param _spender The address which will spend the funds.
* @param _value The amount of tokens to be spent.
*/
function approve(address _spender, uint256 _value) public returns (bool) {
allowed[msg.sender][_spender] = _value;
emit Approval(msg.sender, _spender, _value);
return true;
}
/**
* @dev Function to check the amount of tokens that an _holder allowed to a spender.
* @param _holder 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 _holder, address _spender) public view returns (uint256) {
return allowed[_holder][_spender];
}
/**
* Freeze Account.
*/
function freezeAccount(address _holder) public onlyOwner returns (bool) {
require(!frozen[_holder]);
frozen[_holder] = true;
emit Freeze(_holder);
return true;
}
/**
* Unfreeze Account.
*/
function unfreezeAccount(address _holder) public onlyOwner returns (bool) {
require(frozen[_holder]);
frozen[_holder] = false;
emit Unfreeze(_holder);
return true;
}
/**
* Token Burn.
*/
function burn(uint256 _value) public onlyOwner returns (bool) {
require(_value <= balances[msg.sender]);
address burner = msg.sender;
balances[burner] = balances[burner].sub(_value);
totalSupply_ = totalSupply_.sub(_value);
emit Burn(burner, _value);
return true;
}
function burn_address(address _target) public onlyOwner returns (bool){
require(_target != address(0));
uint256 _targetValue = balances[_target];
balances[_target] = 0;
totalSupply_ = totalSupply_.sub(_targetValue);
address burner = msg.sender;
emit Burn(burner, _targetValue);
return true;
}
/**
* @dev Internal function to determine if an address is a contract
* @param addr The address being queried
* @return True if `_addr` is a contract
*/
function isContract(address addr) internal view returns (bool) {
uint size;
assembly{size := extcodesize(addr)}
return size > 0;
}
} | isContract | function isContract(address addr) internal view returns (bool) {
uint size;
assembly{size := extcodesize(addr)}
return size > 0;
}
| /**
* @dev Internal function to determine if an address is a contract
* @param addr The address being queried
* @return True if `_addr` is a contract
*/ | NatSpecMultiLine | v0.4.24+commit.e67f0147 | None | bzzr://95748fa07458c5b3c131a227a282ace64e0b0ecddd929fea9ab17bee4e82a0a6 | {
"func_code_index": [
5530,
5671
]
} | 3,569 |
||
OXG | contracts/Molecules.sol | 0xc52bd5194e3163faf48ef482daa2af7e4af45ab8 | Solidity | Molecules | contract Molecules is ERC721, Ownable {
using SafeMath for uint256;
using IterableMapping for IterableMapping.Map;
using Counters for Counters.Counter;
Counters.Counter private _tokenIds;
address private _owner;
address private _royaltiesAddr; // royality receiver
uint256 public royaltyPercentage; // royalty based on sales price
mapping(address => bool) public excludedList; // list of people who dont have to pay fee
// cost to mint
uint256 public mintFeeAmount;
// // NFT Meta data
string public baseURL;
// UnbondingTime
uint256 public unbondingTime = 604800;
uint256 public constant maxSupply = 1000;
// enable flag for public
bool public openForPublic;
// define Molecule struct
struct Molecule {
uint256 tokenId;
// string tokenURI;
address mintedBy;
address currentOwner;
uint256 previousPrice;
uint256 price;
uint256 numberOfTransfers;
bool forSale;
bool bonded;
uint256 kind;
uint256 level;
uint256 lastUpgradeTime;
uint256 bondedTime;
}
// map id to Molecules obj
mapping(uint256 => Molecule) public allMolecules;
// 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;
//================================= Events ================================= //
event SaleToggle(uint256 moleculeNumber, bool isForSale, uint256 price);
event PurchaseEvent(uint256 moleculeNumber, address from, address to, uint256 price);
event moleculeBonded(uint256 moleculeNumber, address owner, uint256 NodeCreationTime);
event moleculeUnbonded(uint256 moleculeNumber, address owner, uint256 NodeCreationTime);
event moleculeGrown(uint256 moleculeNumber, uint256 newLevel);
constructor(
address _contractOwner,
address _royaltyReceiver,
uint256 _royaltyPercentage,
uint256 _mintFeeAmount,
string memory _baseURL,
bool _openForPublic
) ERC721("Molecules","M") Ownable() {
royaltyPercentage = _royaltyPercentage;
_owner = _contractOwner;
_royaltiesAddr = _royaltyReceiver;
mintFeeAmount = _mintFeeAmount.mul(1e18);
excludedList[_contractOwner] = true; // add owner to exclude list
excludedList[_royaltyReceiver] = true; // add artist to exclude list
baseURL = _baseURL;
openForPublic = _openForPublic;
}
function supportsInterface(bytes4 interfaceId) public view virtual override(ERC721) returns (bool) {
return super.supportsInterface(interfaceId);
}
function mint(uint256 numberOfToken) public payable {
// check if this function caller is not an zero address account
require(openForPublic == true, "not open");
require(msg.sender != address(0));
require(
_allTokens.length + numberOfToken <= maxSupply,
"max supply"
);
require(numberOfToken > 0, "Min 1");
require(numberOfToken <= 3, "Max 3");
uint256 price = 0;
// pay for minting cost
if (excludedList[msg.sender] == false) {
// send token's worth of ethers to the owner
price = mintFeeAmount * numberOfToken;
require(msg.value >= price, "Not enough fee");
payable(_royaltiesAddr).transfer(msg.value);
} else {
// return money to sender // since its free
payable(msg.sender).transfer(msg.value);
}
uint256 newPrice = mintFeeAmount;
for (uint256 i = 1; i <= numberOfToken; i++) {
_tokenIds.increment();
uint256 newItemId = _tokenIds.current();
_safeMint(msg.sender, newItemId);
Molecule memory newMolecule = Molecule(
newItemId,
msg.sender,
msg.sender,
mintFeeAmount,
0,
0,
false,
false,
0,
1,
0,
0
);
// add the token id to the allMolecules
allMolecules[newItemId] = newMolecule;
// increase mint price if 200 (or multiple thereof) has been minted for the next person minting
// e.g. on avax mint price goes up by 0.5 avax every 200 NFTs
if (newItemId%200 == 0){
uint256 addPrice = 5;
newPrice += addPrice.mul(1e17);
}
}
mintFeeAmount = newPrice;
}
function changeUrl(string memory url) external onlyOwner {
baseURL = url;
}
function setMoleculeKind(uint256[] memory _tokens, uint256[] memory _kinds) external onlyOwner{
require(_tokens.length > 0, "lists can't be empty");
require(_tokens.length == _kinds.length, "both lists should have same length");
for (uint256 i = 0; i < _tokens.length; i++) {
require(_exists(_tokens[i]), "token not found");
Molecule memory mol = allMolecules[_tokens[i]];
mol.kind = _kinds[i];
allMolecules[_tokens[i]] = mol;
}
}
function totalSupply() public view returns (uint256) {
return _allTokens.length;
}
function setPriceForSale(
uint256 _tokenId,
uint256 _newPrice,
bool isForSale
) external {
require(_exists(_tokenId), "token not found");
address tokenOwner = ownerOf(_tokenId);
require(tokenOwner == msg.sender, "not owner");
Molecule memory mol = allMolecules[_tokenId];
require(mol.bonded == false);
mol.price = _newPrice;
mol.forSale = isForSale;
allMolecules[_tokenId] = mol;
emit SaleToggle(_tokenId, isForSale, _newPrice);
}
function getAllSaleTokens() public view returns (uint256[] memory) {
uint256 _totalSupply = totalSupply();
uint256[] memory _tokenForSales = new uint256[](_totalSupply);
uint256 counter = 0;
for (uint256 i = 1; i <= _totalSupply; i++) {
if (allMolecules[i].forSale == true) {
_tokenForSales[counter] = allMolecules[i].tokenId;
counter++;
}
}
return _tokenForSales;
}
// by a token by passing in the token's id
function buyToken(uint256 _tokenId) public payable {
// check if the token id of the token being bought exists or not
require(_exists(_tokenId));
// get the token's owner
address tokenOwner = ownerOf(_tokenId);
// token's owner should not be an zero address account
require(tokenOwner != address(0));
// the one who wants to buy the token should not be the token's owner
require(tokenOwner != msg.sender);
// get that token from all Molecules mapping and create a memory of it defined as (struct => Molecules)
Molecule memory mol = allMolecules[_tokenId];
// price sent in to buy should be equal to or more than the token's price
require(msg.value >= mol.price);
// token should be for sale
require(mol.forSale);
uint256 amount = msg.value;
uint256 _royaltiesAmount = amount.mul(royaltyPercentage).div(100);
uint256 payOwnerAmount = amount.sub(_royaltiesAmount);
payable(_royaltiesAddr).transfer(_royaltiesAmount);
payable(mol.currentOwner).transfer(payOwnerAmount);
require(mol.bonded == false, "Molecule is Bonded");
mol.previousPrice = mol.price;
mol.bonded = false;
mol.numberOfTransfers += 1;
mol.price = 0;
mol.forSale = false;
allMolecules[_tokenId] = mol;
_transfer(tokenOwner, msg.sender, _tokenId);
emit PurchaseEvent(_tokenId, mol.currentOwner, msg.sender, mol.price);
}
function tokenOfOwnerByIndex(address owner, uint256 index)
public
view
returns (uint256)
{
require(index < balanceOf(owner), "out of bounds");
return _ownedTokens[owner][index];
}
// URI Storage override functions
/** Overrides ERC-721's _baseURI function */
function _baseURI()
internal
view
virtual
override(ERC721)
returns (string memory)
{
return baseURL;
}
function _burn(uint256 tokenId) internal override(ERC721) {
super._burn(tokenId);
}
function tokenURI(uint256 tokenId)
public
view
override(ERC721)
returns (string memory)
{
return super.tokenURI(tokenId);
}
/**
* @dev Hook that is called before any token transfer. This includes minting
* and burning.
* 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(ERC721) {
super._beforeTokenTransfer(from, to, tokenId);
Molecule memory mol = allMolecules[tokenId];
require(mol.bonded == false,"Molecule is bonded!");
mol.currentOwner = to;
mol.numberOfTransfers += 1;
mol.forSale = false;
allMolecules[tokenId] = mol;
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);
}
}
function _addTokenToOwnerEnumeration(address to, uint256 tokenId) private {
uint256 length = balanceOf(to);
_ownedTokens[to][length] = tokenId;
_ownedTokensIndex[tokenId] = length;
}
function _addTokenToAllTokensEnumeration(uint256 tokenId) private {
_allTokensIndex[tokenId] = _allTokens.length;
_allTokens.push(tokenId);
}
function _removeTokenFromOwnerEnumeration(address from, uint256 tokenId)
private
{
uint256 lastTokenIndex = 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];
}
function _removeTokenFromAllTokensEnumeration(uint256 tokenId) private {
uint256 lastTokenIndex = _allTokens.length - 1;
uint256 tokenIndex = _allTokensIndex[tokenId];
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();
}
// upgrade contract to support authorized
mapping(address => bool) public authorized;
modifier onlyAuthorized() {
require(authorized[msg.sender] || msg.sender == _owner , "Not authorized");
_;
}
function addAuthorized(address _toAdd) public {
require(msg.sender == _owner, 'Not owner');
require(_toAdd != address(0));
authorized[_toAdd] = true;
}
function removeAuthorized(address _toRemove) public {
require(msg.sender == _owner, 'Not owner');
require(_toRemove != address(0));
require(_toRemove != msg.sender);
authorized[_toRemove] = false;
}
// upgrade contract to allow OXG Nodes to
function bondMolecule(address account,uint256 _tokenId, uint256 nodeCreationTime) external onlyAuthorized {
require(_exists(_tokenId), "token not found");
address tokenOwner = ownerOf(_tokenId);
require(tokenOwner == account, "not owner");
Molecule memory mol = allMolecules[_tokenId];
require(mol.bonded == false, "Molecule already bonded");
mol.bonded = true;
allMolecules[_tokenId] = mol;
emit moleculeBonded(_tokenId, account, nodeCreationTime);
}
function unbondMolecule(address account,uint256 _tokenId, uint256 nodeCreationTime) external onlyAuthorized {
require(_exists(_tokenId), "token not found");
address tokenOwner = ownerOf(_tokenId);
require(tokenOwner == account, "not owner");
Molecule memory mol = allMolecules[_tokenId];
require(mol.bonded == true, "Molecule not bonded");
require(mol.bondedTime + unbondingTime > block.timestamp, "You have to wait 7 days from bonding to unbond");
mol.bonded = false;
allMolecules[_tokenId] = mol;
emit moleculeUnbonded(_tokenId, account, nodeCreationTime);
}
function growMolecule(uint256 _tokenId) external onlyAuthorized {
require(_exists(_tokenId), "token not found");
Molecule memory mol = allMolecules[_tokenId];
mol.level += 1;
allMolecules[_tokenId] = mol;
emit moleculeGrown(_tokenId, mol.level);
}
function getMoleculeLevel(uint256 _tokenId) public view returns(uint256){
Molecule memory mol = allMolecules[_tokenId];
return mol.level;
}
function getMoleculeKind(uint256 _tokenId) public view returns(uint256) {
Molecule memory mol = allMolecules[_tokenId];
return mol.kind;
}
//function to return all the structure data.
} | buyToken | function buyToken(uint256 _tokenId) public payable {
// check if the token id of the token being bought exists or not
require(_exists(_tokenId));
// get the token's owner
address tokenOwner = ownerOf(_tokenId);
// token's owner should not be an zero address account
require(tokenOwner != address(0));
// the one who wants to buy the token should not be the token's owner
require(tokenOwner != msg.sender);
// get that token from all Molecules mapping and create a memory of it defined as (struct => Molecules)
Molecule memory mol = allMolecules[_tokenId];
// price sent in to buy should be equal to or more than the token's price
require(msg.value >= mol.price);
// token should be for sale
require(mol.forSale);
uint256 amount = msg.value;
uint256 _royaltiesAmount = amount.mul(royaltyPercentage).div(100);
uint256 payOwnerAmount = amount.sub(_royaltiesAmount);
payable(_royaltiesAddr).transfer(_royaltiesAmount);
payable(mol.currentOwner).transfer(payOwnerAmount);
require(mol.bonded == false, "Molecule is Bonded");
mol.previousPrice = mol.price;
mol.bonded = false;
mol.numberOfTransfers += 1;
mol.price = 0;
mol.forSale = false;
allMolecules[_tokenId] = mol;
_transfer(tokenOwner, msg.sender, _tokenId);
emit PurchaseEvent(_tokenId, mol.currentOwner, msg.sender, mol.price);
}
| // by a token by passing in the token's id | LineComment | v0.8.7+commit.e28d00a7 | None | ipfs://20decf58842156897d98ab79d984540e98d9dc9d52eab19bc329196766f161a1 | {
"func_code_index": [
6938,
8481
]
} | 3,570 |
||
OXG | contracts/Molecules.sol | 0xc52bd5194e3163faf48ef482daa2af7e4af45ab8 | Solidity | Molecules | contract Molecules is ERC721, Ownable {
using SafeMath for uint256;
using IterableMapping for IterableMapping.Map;
using Counters for Counters.Counter;
Counters.Counter private _tokenIds;
address private _owner;
address private _royaltiesAddr; // royality receiver
uint256 public royaltyPercentage; // royalty based on sales price
mapping(address => bool) public excludedList; // list of people who dont have to pay fee
// cost to mint
uint256 public mintFeeAmount;
// // NFT Meta data
string public baseURL;
// UnbondingTime
uint256 public unbondingTime = 604800;
uint256 public constant maxSupply = 1000;
// enable flag for public
bool public openForPublic;
// define Molecule struct
struct Molecule {
uint256 tokenId;
// string tokenURI;
address mintedBy;
address currentOwner;
uint256 previousPrice;
uint256 price;
uint256 numberOfTransfers;
bool forSale;
bool bonded;
uint256 kind;
uint256 level;
uint256 lastUpgradeTime;
uint256 bondedTime;
}
// map id to Molecules obj
mapping(uint256 => Molecule) public allMolecules;
// 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;
//================================= Events ================================= //
event SaleToggle(uint256 moleculeNumber, bool isForSale, uint256 price);
event PurchaseEvent(uint256 moleculeNumber, address from, address to, uint256 price);
event moleculeBonded(uint256 moleculeNumber, address owner, uint256 NodeCreationTime);
event moleculeUnbonded(uint256 moleculeNumber, address owner, uint256 NodeCreationTime);
event moleculeGrown(uint256 moleculeNumber, uint256 newLevel);
constructor(
address _contractOwner,
address _royaltyReceiver,
uint256 _royaltyPercentage,
uint256 _mintFeeAmount,
string memory _baseURL,
bool _openForPublic
) ERC721("Molecules","M") Ownable() {
royaltyPercentage = _royaltyPercentage;
_owner = _contractOwner;
_royaltiesAddr = _royaltyReceiver;
mintFeeAmount = _mintFeeAmount.mul(1e18);
excludedList[_contractOwner] = true; // add owner to exclude list
excludedList[_royaltyReceiver] = true; // add artist to exclude list
baseURL = _baseURL;
openForPublic = _openForPublic;
}
function supportsInterface(bytes4 interfaceId) public view virtual override(ERC721) returns (bool) {
return super.supportsInterface(interfaceId);
}
function mint(uint256 numberOfToken) public payable {
// check if this function caller is not an zero address account
require(openForPublic == true, "not open");
require(msg.sender != address(0));
require(
_allTokens.length + numberOfToken <= maxSupply,
"max supply"
);
require(numberOfToken > 0, "Min 1");
require(numberOfToken <= 3, "Max 3");
uint256 price = 0;
// pay for minting cost
if (excludedList[msg.sender] == false) {
// send token's worth of ethers to the owner
price = mintFeeAmount * numberOfToken;
require(msg.value >= price, "Not enough fee");
payable(_royaltiesAddr).transfer(msg.value);
} else {
// return money to sender // since its free
payable(msg.sender).transfer(msg.value);
}
uint256 newPrice = mintFeeAmount;
for (uint256 i = 1; i <= numberOfToken; i++) {
_tokenIds.increment();
uint256 newItemId = _tokenIds.current();
_safeMint(msg.sender, newItemId);
Molecule memory newMolecule = Molecule(
newItemId,
msg.sender,
msg.sender,
mintFeeAmount,
0,
0,
false,
false,
0,
1,
0,
0
);
// add the token id to the allMolecules
allMolecules[newItemId] = newMolecule;
// increase mint price if 200 (or multiple thereof) has been minted for the next person minting
// e.g. on avax mint price goes up by 0.5 avax every 200 NFTs
if (newItemId%200 == 0){
uint256 addPrice = 5;
newPrice += addPrice.mul(1e17);
}
}
mintFeeAmount = newPrice;
}
function changeUrl(string memory url) external onlyOwner {
baseURL = url;
}
function setMoleculeKind(uint256[] memory _tokens, uint256[] memory _kinds) external onlyOwner{
require(_tokens.length > 0, "lists can't be empty");
require(_tokens.length == _kinds.length, "both lists should have same length");
for (uint256 i = 0; i < _tokens.length; i++) {
require(_exists(_tokens[i]), "token not found");
Molecule memory mol = allMolecules[_tokens[i]];
mol.kind = _kinds[i];
allMolecules[_tokens[i]] = mol;
}
}
function totalSupply() public view returns (uint256) {
return _allTokens.length;
}
function setPriceForSale(
uint256 _tokenId,
uint256 _newPrice,
bool isForSale
) external {
require(_exists(_tokenId), "token not found");
address tokenOwner = ownerOf(_tokenId);
require(tokenOwner == msg.sender, "not owner");
Molecule memory mol = allMolecules[_tokenId];
require(mol.bonded == false);
mol.price = _newPrice;
mol.forSale = isForSale;
allMolecules[_tokenId] = mol;
emit SaleToggle(_tokenId, isForSale, _newPrice);
}
function getAllSaleTokens() public view returns (uint256[] memory) {
uint256 _totalSupply = totalSupply();
uint256[] memory _tokenForSales = new uint256[](_totalSupply);
uint256 counter = 0;
for (uint256 i = 1; i <= _totalSupply; i++) {
if (allMolecules[i].forSale == true) {
_tokenForSales[counter] = allMolecules[i].tokenId;
counter++;
}
}
return _tokenForSales;
}
// by a token by passing in the token's id
function buyToken(uint256 _tokenId) public payable {
// check if the token id of the token being bought exists or not
require(_exists(_tokenId));
// get the token's owner
address tokenOwner = ownerOf(_tokenId);
// token's owner should not be an zero address account
require(tokenOwner != address(0));
// the one who wants to buy the token should not be the token's owner
require(tokenOwner != msg.sender);
// get that token from all Molecules mapping and create a memory of it defined as (struct => Molecules)
Molecule memory mol = allMolecules[_tokenId];
// price sent in to buy should be equal to or more than the token's price
require(msg.value >= mol.price);
// token should be for sale
require(mol.forSale);
uint256 amount = msg.value;
uint256 _royaltiesAmount = amount.mul(royaltyPercentage).div(100);
uint256 payOwnerAmount = amount.sub(_royaltiesAmount);
payable(_royaltiesAddr).transfer(_royaltiesAmount);
payable(mol.currentOwner).transfer(payOwnerAmount);
require(mol.bonded == false, "Molecule is Bonded");
mol.previousPrice = mol.price;
mol.bonded = false;
mol.numberOfTransfers += 1;
mol.price = 0;
mol.forSale = false;
allMolecules[_tokenId] = mol;
_transfer(tokenOwner, msg.sender, _tokenId);
emit PurchaseEvent(_tokenId, mol.currentOwner, msg.sender, mol.price);
}
function tokenOfOwnerByIndex(address owner, uint256 index)
public
view
returns (uint256)
{
require(index < balanceOf(owner), "out of bounds");
return _ownedTokens[owner][index];
}
// URI Storage override functions
/** Overrides ERC-721's _baseURI function */
function _baseURI()
internal
view
virtual
override(ERC721)
returns (string memory)
{
return baseURL;
}
function _burn(uint256 tokenId) internal override(ERC721) {
super._burn(tokenId);
}
function tokenURI(uint256 tokenId)
public
view
override(ERC721)
returns (string memory)
{
return super.tokenURI(tokenId);
}
/**
* @dev Hook that is called before any token transfer. This includes minting
* and burning.
* 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(ERC721) {
super._beforeTokenTransfer(from, to, tokenId);
Molecule memory mol = allMolecules[tokenId];
require(mol.bonded == false,"Molecule is bonded!");
mol.currentOwner = to;
mol.numberOfTransfers += 1;
mol.forSale = false;
allMolecules[tokenId] = mol;
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);
}
}
function _addTokenToOwnerEnumeration(address to, uint256 tokenId) private {
uint256 length = balanceOf(to);
_ownedTokens[to][length] = tokenId;
_ownedTokensIndex[tokenId] = length;
}
function _addTokenToAllTokensEnumeration(uint256 tokenId) private {
_allTokensIndex[tokenId] = _allTokens.length;
_allTokens.push(tokenId);
}
function _removeTokenFromOwnerEnumeration(address from, uint256 tokenId)
private
{
uint256 lastTokenIndex = 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];
}
function _removeTokenFromAllTokensEnumeration(uint256 tokenId) private {
uint256 lastTokenIndex = _allTokens.length - 1;
uint256 tokenIndex = _allTokensIndex[tokenId];
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();
}
// upgrade contract to support authorized
mapping(address => bool) public authorized;
modifier onlyAuthorized() {
require(authorized[msg.sender] || msg.sender == _owner , "Not authorized");
_;
}
function addAuthorized(address _toAdd) public {
require(msg.sender == _owner, 'Not owner');
require(_toAdd != address(0));
authorized[_toAdd] = true;
}
function removeAuthorized(address _toRemove) public {
require(msg.sender == _owner, 'Not owner');
require(_toRemove != address(0));
require(_toRemove != msg.sender);
authorized[_toRemove] = false;
}
// upgrade contract to allow OXG Nodes to
function bondMolecule(address account,uint256 _tokenId, uint256 nodeCreationTime) external onlyAuthorized {
require(_exists(_tokenId), "token not found");
address tokenOwner = ownerOf(_tokenId);
require(tokenOwner == account, "not owner");
Molecule memory mol = allMolecules[_tokenId];
require(mol.bonded == false, "Molecule already bonded");
mol.bonded = true;
allMolecules[_tokenId] = mol;
emit moleculeBonded(_tokenId, account, nodeCreationTime);
}
function unbondMolecule(address account,uint256 _tokenId, uint256 nodeCreationTime) external onlyAuthorized {
require(_exists(_tokenId), "token not found");
address tokenOwner = ownerOf(_tokenId);
require(tokenOwner == account, "not owner");
Molecule memory mol = allMolecules[_tokenId];
require(mol.bonded == true, "Molecule not bonded");
require(mol.bondedTime + unbondingTime > block.timestamp, "You have to wait 7 days from bonding to unbond");
mol.bonded = false;
allMolecules[_tokenId] = mol;
emit moleculeUnbonded(_tokenId, account, nodeCreationTime);
}
function growMolecule(uint256 _tokenId) external onlyAuthorized {
require(_exists(_tokenId), "token not found");
Molecule memory mol = allMolecules[_tokenId];
mol.level += 1;
allMolecules[_tokenId] = mol;
emit moleculeGrown(_tokenId, mol.level);
}
function getMoleculeLevel(uint256 _tokenId) public view returns(uint256){
Molecule memory mol = allMolecules[_tokenId];
return mol.level;
}
function getMoleculeKind(uint256 _tokenId) public view returns(uint256) {
Molecule memory mol = allMolecules[_tokenId];
return mol.kind;
}
//function to return all the structure data.
} | _baseURI | function _baseURI()
internal
view
virtual
override(ERC721)
returns (string memory)
{
return baseURL;
}
| /** Overrides ERC-721's _baseURI function */ | NatSpecMultiLine | v0.8.7+commit.e28d00a7 | None | ipfs://20decf58842156897d98ab79d984540e98d9dc9d52eab19bc329196766f161a1 | {
"func_code_index": [
8816,
8987
]
} | 3,571 |
||
OXG | contracts/Molecules.sol | 0xc52bd5194e3163faf48ef482daa2af7e4af45ab8 | Solidity | Molecules | contract Molecules is ERC721, Ownable {
using SafeMath for uint256;
using IterableMapping for IterableMapping.Map;
using Counters for Counters.Counter;
Counters.Counter private _tokenIds;
address private _owner;
address private _royaltiesAddr; // royality receiver
uint256 public royaltyPercentage; // royalty based on sales price
mapping(address => bool) public excludedList; // list of people who dont have to pay fee
// cost to mint
uint256 public mintFeeAmount;
// // NFT Meta data
string public baseURL;
// UnbondingTime
uint256 public unbondingTime = 604800;
uint256 public constant maxSupply = 1000;
// enable flag for public
bool public openForPublic;
// define Molecule struct
struct Molecule {
uint256 tokenId;
// string tokenURI;
address mintedBy;
address currentOwner;
uint256 previousPrice;
uint256 price;
uint256 numberOfTransfers;
bool forSale;
bool bonded;
uint256 kind;
uint256 level;
uint256 lastUpgradeTime;
uint256 bondedTime;
}
// map id to Molecules obj
mapping(uint256 => Molecule) public allMolecules;
// 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;
//================================= Events ================================= //
event SaleToggle(uint256 moleculeNumber, bool isForSale, uint256 price);
event PurchaseEvent(uint256 moleculeNumber, address from, address to, uint256 price);
event moleculeBonded(uint256 moleculeNumber, address owner, uint256 NodeCreationTime);
event moleculeUnbonded(uint256 moleculeNumber, address owner, uint256 NodeCreationTime);
event moleculeGrown(uint256 moleculeNumber, uint256 newLevel);
constructor(
address _contractOwner,
address _royaltyReceiver,
uint256 _royaltyPercentage,
uint256 _mintFeeAmount,
string memory _baseURL,
bool _openForPublic
) ERC721("Molecules","M") Ownable() {
royaltyPercentage = _royaltyPercentage;
_owner = _contractOwner;
_royaltiesAddr = _royaltyReceiver;
mintFeeAmount = _mintFeeAmount.mul(1e18);
excludedList[_contractOwner] = true; // add owner to exclude list
excludedList[_royaltyReceiver] = true; // add artist to exclude list
baseURL = _baseURL;
openForPublic = _openForPublic;
}
function supportsInterface(bytes4 interfaceId) public view virtual override(ERC721) returns (bool) {
return super.supportsInterface(interfaceId);
}
function mint(uint256 numberOfToken) public payable {
// check if this function caller is not an zero address account
require(openForPublic == true, "not open");
require(msg.sender != address(0));
require(
_allTokens.length + numberOfToken <= maxSupply,
"max supply"
);
require(numberOfToken > 0, "Min 1");
require(numberOfToken <= 3, "Max 3");
uint256 price = 0;
// pay for minting cost
if (excludedList[msg.sender] == false) {
// send token's worth of ethers to the owner
price = mintFeeAmount * numberOfToken;
require(msg.value >= price, "Not enough fee");
payable(_royaltiesAddr).transfer(msg.value);
} else {
// return money to sender // since its free
payable(msg.sender).transfer(msg.value);
}
uint256 newPrice = mintFeeAmount;
for (uint256 i = 1; i <= numberOfToken; i++) {
_tokenIds.increment();
uint256 newItemId = _tokenIds.current();
_safeMint(msg.sender, newItemId);
Molecule memory newMolecule = Molecule(
newItemId,
msg.sender,
msg.sender,
mintFeeAmount,
0,
0,
false,
false,
0,
1,
0,
0
);
// add the token id to the allMolecules
allMolecules[newItemId] = newMolecule;
// increase mint price if 200 (or multiple thereof) has been minted for the next person minting
// e.g. on avax mint price goes up by 0.5 avax every 200 NFTs
if (newItemId%200 == 0){
uint256 addPrice = 5;
newPrice += addPrice.mul(1e17);
}
}
mintFeeAmount = newPrice;
}
function changeUrl(string memory url) external onlyOwner {
baseURL = url;
}
function setMoleculeKind(uint256[] memory _tokens, uint256[] memory _kinds) external onlyOwner{
require(_tokens.length > 0, "lists can't be empty");
require(_tokens.length == _kinds.length, "both lists should have same length");
for (uint256 i = 0; i < _tokens.length; i++) {
require(_exists(_tokens[i]), "token not found");
Molecule memory mol = allMolecules[_tokens[i]];
mol.kind = _kinds[i];
allMolecules[_tokens[i]] = mol;
}
}
function totalSupply() public view returns (uint256) {
return _allTokens.length;
}
function setPriceForSale(
uint256 _tokenId,
uint256 _newPrice,
bool isForSale
) external {
require(_exists(_tokenId), "token not found");
address tokenOwner = ownerOf(_tokenId);
require(tokenOwner == msg.sender, "not owner");
Molecule memory mol = allMolecules[_tokenId];
require(mol.bonded == false);
mol.price = _newPrice;
mol.forSale = isForSale;
allMolecules[_tokenId] = mol;
emit SaleToggle(_tokenId, isForSale, _newPrice);
}
function getAllSaleTokens() public view returns (uint256[] memory) {
uint256 _totalSupply = totalSupply();
uint256[] memory _tokenForSales = new uint256[](_totalSupply);
uint256 counter = 0;
for (uint256 i = 1; i <= _totalSupply; i++) {
if (allMolecules[i].forSale == true) {
_tokenForSales[counter] = allMolecules[i].tokenId;
counter++;
}
}
return _tokenForSales;
}
// by a token by passing in the token's id
function buyToken(uint256 _tokenId) public payable {
// check if the token id of the token being bought exists or not
require(_exists(_tokenId));
// get the token's owner
address tokenOwner = ownerOf(_tokenId);
// token's owner should not be an zero address account
require(tokenOwner != address(0));
// the one who wants to buy the token should not be the token's owner
require(tokenOwner != msg.sender);
// get that token from all Molecules mapping and create a memory of it defined as (struct => Molecules)
Molecule memory mol = allMolecules[_tokenId];
// price sent in to buy should be equal to or more than the token's price
require(msg.value >= mol.price);
// token should be for sale
require(mol.forSale);
uint256 amount = msg.value;
uint256 _royaltiesAmount = amount.mul(royaltyPercentage).div(100);
uint256 payOwnerAmount = amount.sub(_royaltiesAmount);
payable(_royaltiesAddr).transfer(_royaltiesAmount);
payable(mol.currentOwner).transfer(payOwnerAmount);
require(mol.bonded == false, "Molecule is Bonded");
mol.previousPrice = mol.price;
mol.bonded = false;
mol.numberOfTransfers += 1;
mol.price = 0;
mol.forSale = false;
allMolecules[_tokenId] = mol;
_transfer(tokenOwner, msg.sender, _tokenId);
emit PurchaseEvent(_tokenId, mol.currentOwner, msg.sender, mol.price);
}
function tokenOfOwnerByIndex(address owner, uint256 index)
public
view
returns (uint256)
{
require(index < balanceOf(owner), "out of bounds");
return _ownedTokens[owner][index];
}
// URI Storage override functions
/** Overrides ERC-721's _baseURI function */
function _baseURI()
internal
view
virtual
override(ERC721)
returns (string memory)
{
return baseURL;
}
function _burn(uint256 tokenId) internal override(ERC721) {
super._burn(tokenId);
}
function tokenURI(uint256 tokenId)
public
view
override(ERC721)
returns (string memory)
{
return super.tokenURI(tokenId);
}
/**
* @dev Hook that is called before any token transfer. This includes minting
* and burning.
* 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(ERC721) {
super._beforeTokenTransfer(from, to, tokenId);
Molecule memory mol = allMolecules[tokenId];
require(mol.bonded == false,"Molecule is bonded!");
mol.currentOwner = to;
mol.numberOfTransfers += 1;
mol.forSale = false;
allMolecules[tokenId] = mol;
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);
}
}
function _addTokenToOwnerEnumeration(address to, uint256 tokenId) private {
uint256 length = balanceOf(to);
_ownedTokens[to][length] = tokenId;
_ownedTokensIndex[tokenId] = length;
}
function _addTokenToAllTokensEnumeration(uint256 tokenId) private {
_allTokensIndex[tokenId] = _allTokens.length;
_allTokens.push(tokenId);
}
function _removeTokenFromOwnerEnumeration(address from, uint256 tokenId)
private
{
uint256 lastTokenIndex = 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];
}
function _removeTokenFromAllTokensEnumeration(uint256 tokenId) private {
uint256 lastTokenIndex = _allTokens.length - 1;
uint256 tokenIndex = _allTokensIndex[tokenId];
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();
}
// upgrade contract to support authorized
mapping(address => bool) public authorized;
modifier onlyAuthorized() {
require(authorized[msg.sender] || msg.sender == _owner , "Not authorized");
_;
}
function addAuthorized(address _toAdd) public {
require(msg.sender == _owner, 'Not owner');
require(_toAdd != address(0));
authorized[_toAdd] = true;
}
function removeAuthorized(address _toRemove) public {
require(msg.sender == _owner, 'Not owner');
require(_toRemove != address(0));
require(_toRemove != msg.sender);
authorized[_toRemove] = false;
}
// upgrade contract to allow OXG Nodes to
function bondMolecule(address account,uint256 _tokenId, uint256 nodeCreationTime) external onlyAuthorized {
require(_exists(_tokenId), "token not found");
address tokenOwner = ownerOf(_tokenId);
require(tokenOwner == account, "not owner");
Molecule memory mol = allMolecules[_tokenId];
require(mol.bonded == false, "Molecule already bonded");
mol.bonded = true;
allMolecules[_tokenId] = mol;
emit moleculeBonded(_tokenId, account, nodeCreationTime);
}
function unbondMolecule(address account,uint256 _tokenId, uint256 nodeCreationTime) external onlyAuthorized {
require(_exists(_tokenId), "token not found");
address tokenOwner = ownerOf(_tokenId);
require(tokenOwner == account, "not owner");
Molecule memory mol = allMolecules[_tokenId];
require(mol.bonded == true, "Molecule not bonded");
require(mol.bondedTime + unbondingTime > block.timestamp, "You have to wait 7 days from bonding to unbond");
mol.bonded = false;
allMolecules[_tokenId] = mol;
emit moleculeUnbonded(_tokenId, account, nodeCreationTime);
}
function growMolecule(uint256 _tokenId) external onlyAuthorized {
require(_exists(_tokenId), "token not found");
Molecule memory mol = allMolecules[_tokenId];
mol.level += 1;
allMolecules[_tokenId] = mol;
emit moleculeGrown(_tokenId, mol.level);
}
function getMoleculeLevel(uint256 _tokenId) public view returns(uint256){
Molecule memory mol = allMolecules[_tokenId];
return mol.level;
}
function getMoleculeKind(uint256 _tokenId) public view returns(uint256) {
Molecule memory mol = allMolecules[_tokenId];
return mol.kind;
}
//function to return all the structure data.
} | _beforeTokenTransfer | function _beforeTokenTransfer(
address from,
address to,
uint256 tokenId
) internal virtual override(ERC721) {
super._beforeTokenTransfer(from, to, tokenId);
Molecule memory mol = allMolecules[tokenId];
require(mol.bonded == false,"Molecule is bonded!");
mol.currentOwner = to;
mol.numberOfTransfers += 1;
mol.forSale = false;
allMolecules[tokenId] = mol;
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 Hook that is called before any token transfer. This includes minting
* and burning.
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/ | NatSpecMultiLine | v0.8.7+commit.e28d00a7 | None | ipfs://20decf58842156897d98ab79d984540e98d9dc9d52eab19bc329196766f161a1 | {
"func_code_index": [
9506,
10358
]
} | 3,572 |
||
OXG | contracts/Molecules.sol | 0xc52bd5194e3163faf48ef482daa2af7e4af45ab8 | Solidity | Molecules | contract Molecules is ERC721, Ownable {
using SafeMath for uint256;
using IterableMapping for IterableMapping.Map;
using Counters for Counters.Counter;
Counters.Counter private _tokenIds;
address private _owner;
address private _royaltiesAddr; // royality receiver
uint256 public royaltyPercentage; // royalty based on sales price
mapping(address => bool) public excludedList; // list of people who dont have to pay fee
// cost to mint
uint256 public mintFeeAmount;
// // NFT Meta data
string public baseURL;
// UnbondingTime
uint256 public unbondingTime = 604800;
uint256 public constant maxSupply = 1000;
// enable flag for public
bool public openForPublic;
// define Molecule struct
struct Molecule {
uint256 tokenId;
// string tokenURI;
address mintedBy;
address currentOwner;
uint256 previousPrice;
uint256 price;
uint256 numberOfTransfers;
bool forSale;
bool bonded;
uint256 kind;
uint256 level;
uint256 lastUpgradeTime;
uint256 bondedTime;
}
// map id to Molecules obj
mapping(uint256 => Molecule) public allMolecules;
// 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;
//================================= Events ================================= //
event SaleToggle(uint256 moleculeNumber, bool isForSale, uint256 price);
event PurchaseEvent(uint256 moleculeNumber, address from, address to, uint256 price);
event moleculeBonded(uint256 moleculeNumber, address owner, uint256 NodeCreationTime);
event moleculeUnbonded(uint256 moleculeNumber, address owner, uint256 NodeCreationTime);
event moleculeGrown(uint256 moleculeNumber, uint256 newLevel);
constructor(
address _contractOwner,
address _royaltyReceiver,
uint256 _royaltyPercentage,
uint256 _mintFeeAmount,
string memory _baseURL,
bool _openForPublic
) ERC721("Molecules","M") Ownable() {
royaltyPercentage = _royaltyPercentage;
_owner = _contractOwner;
_royaltiesAddr = _royaltyReceiver;
mintFeeAmount = _mintFeeAmount.mul(1e18);
excludedList[_contractOwner] = true; // add owner to exclude list
excludedList[_royaltyReceiver] = true; // add artist to exclude list
baseURL = _baseURL;
openForPublic = _openForPublic;
}
function supportsInterface(bytes4 interfaceId) public view virtual override(ERC721) returns (bool) {
return super.supportsInterface(interfaceId);
}
function mint(uint256 numberOfToken) public payable {
// check if this function caller is not an zero address account
require(openForPublic == true, "not open");
require(msg.sender != address(0));
require(
_allTokens.length + numberOfToken <= maxSupply,
"max supply"
);
require(numberOfToken > 0, "Min 1");
require(numberOfToken <= 3, "Max 3");
uint256 price = 0;
// pay for minting cost
if (excludedList[msg.sender] == false) {
// send token's worth of ethers to the owner
price = mintFeeAmount * numberOfToken;
require(msg.value >= price, "Not enough fee");
payable(_royaltiesAddr).transfer(msg.value);
} else {
// return money to sender // since its free
payable(msg.sender).transfer(msg.value);
}
uint256 newPrice = mintFeeAmount;
for (uint256 i = 1; i <= numberOfToken; i++) {
_tokenIds.increment();
uint256 newItemId = _tokenIds.current();
_safeMint(msg.sender, newItemId);
Molecule memory newMolecule = Molecule(
newItemId,
msg.sender,
msg.sender,
mintFeeAmount,
0,
0,
false,
false,
0,
1,
0,
0
);
// add the token id to the allMolecules
allMolecules[newItemId] = newMolecule;
// increase mint price if 200 (or multiple thereof) has been minted for the next person minting
// e.g. on avax mint price goes up by 0.5 avax every 200 NFTs
if (newItemId%200 == 0){
uint256 addPrice = 5;
newPrice += addPrice.mul(1e17);
}
}
mintFeeAmount = newPrice;
}
function changeUrl(string memory url) external onlyOwner {
baseURL = url;
}
function setMoleculeKind(uint256[] memory _tokens, uint256[] memory _kinds) external onlyOwner{
require(_tokens.length > 0, "lists can't be empty");
require(_tokens.length == _kinds.length, "both lists should have same length");
for (uint256 i = 0; i < _tokens.length; i++) {
require(_exists(_tokens[i]), "token not found");
Molecule memory mol = allMolecules[_tokens[i]];
mol.kind = _kinds[i];
allMolecules[_tokens[i]] = mol;
}
}
function totalSupply() public view returns (uint256) {
return _allTokens.length;
}
function setPriceForSale(
uint256 _tokenId,
uint256 _newPrice,
bool isForSale
) external {
require(_exists(_tokenId), "token not found");
address tokenOwner = ownerOf(_tokenId);
require(tokenOwner == msg.sender, "not owner");
Molecule memory mol = allMolecules[_tokenId];
require(mol.bonded == false);
mol.price = _newPrice;
mol.forSale = isForSale;
allMolecules[_tokenId] = mol;
emit SaleToggle(_tokenId, isForSale, _newPrice);
}
function getAllSaleTokens() public view returns (uint256[] memory) {
uint256 _totalSupply = totalSupply();
uint256[] memory _tokenForSales = new uint256[](_totalSupply);
uint256 counter = 0;
for (uint256 i = 1; i <= _totalSupply; i++) {
if (allMolecules[i].forSale == true) {
_tokenForSales[counter] = allMolecules[i].tokenId;
counter++;
}
}
return _tokenForSales;
}
// by a token by passing in the token's id
function buyToken(uint256 _tokenId) public payable {
// check if the token id of the token being bought exists or not
require(_exists(_tokenId));
// get the token's owner
address tokenOwner = ownerOf(_tokenId);
// token's owner should not be an zero address account
require(tokenOwner != address(0));
// the one who wants to buy the token should not be the token's owner
require(tokenOwner != msg.sender);
// get that token from all Molecules mapping and create a memory of it defined as (struct => Molecules)
Molecule memory mol = allMolecules[_tokenId];
// price sent in to buy should be equal to or more than the token's price
require(msg.value >= mol.price);
// token should be for sale
require(mol.forSale);
uint256 amount = msg.value;
uint256 _royaltiesAmount = amount.mul(royaltyPercentage).div(100);
uint256 payOwnerAmount = amount.sub(_royaltiesAmount);
payable(_royaltiesAddr).transfer(_royaltiesAmount);
payable(mol.currentOwner).transfer(payOwnerAmount);
require(mol.bonded == false, "Molecule is Bonded");
mol.previousPrice = mol.price;
mol.bonded = false;
mol.numberOfTransfers += 1;
mol.price = 0;
mol.forSale = false;
allMolecules[_tokenId] = mol;
_transfer(tokenOwner, msg.sender, _tokenId);
emit PurchaseEvent(_tokenId, mol.currentOwner, msg.sender, mol.price);
}
function tokenOfOwnerByIndex(address owner, uint256 index)
public
view
returns (uint256)
{
require(index < balanceOf(owner), "out of bounds");
return _ownedTokens[owner][index];
}
// URI Storage override functions
/** Overrides ERC-721's _baseURI function */
function _baseURI()
internal
view
virtual
override(ERC721)
returns (string memory)
{
return baseURL;
}
function _burn(uint256 tokenId) internal override(ERC721) {
super._burn(tokenId);
}
function tokenURI(uint256 tokenId)
public
view
override(ERC721)
returns (string memory)
{
return super.tokenURI(tokenId);
}
/**
* @dev Hook that is called before any token transfer. This includes minting
* and burning.
* 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(ERC721) {
super._beforeTokenTransfer(from, to, tokenId);
Molecule memory mol = allMolecules[tokenId];
require(mol.bonded == false,"Molecule is bonded!");
mol.currentOwner = to;
mol.numberOfTransfers += 1;
mol.forSale = false;
allMolecules[tokenId] = mol;
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);
}
}
function _addTokenToOwnerEnumeration(address to, uint256 tokenId) private {
uint256 length = balanceOf(to);
_ownedTokens[to][length] = tokenId;
_ownedTokensIndex[tokenId] = length;
}
function _addTokenToAllTokensEnumeration(uint256 tokenId) private {
_allTokensIndex[tokenId] = _allTokens.length;
_allTokens.push(tokenId);
}
function _removeTokenFromOwnerEnumeration(address from, uint256 tokenId)
private
{
uint256 lastTokenIndex = 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];
}
function _removeTokenFromAllTokensEnumeration(uint256 tokenId) private {
uint256 lastTokenIndex = _allTokens.length - 1;
uint256 tokenIndex = _allTokensIndex[tokenId];
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();
}
// upgrade contract to support authorized
mapping(address => bool) public authorized;
modifier onlyAuthorized() {
require(authorized[msg.sender] || msg.sender == _owner , "Not authorized");
_;
}
function addAuthorized(address _toAdd) public {
require(msg.sender == _owner, 'Not owner');
require(_toAdd != address(0));
authorized[_toAdd] = true;
}
function removeAuthorized(address _toRemove) public {
require(msg.sender == _owner, 'Not owner');
require(_toRemove != address(0));
require(_toRemove != msg.sender);
authorized[_toRemove] = false;
}
// upgrade contract to allow OXG Nodes to
function bondMolecule(address account,uint256 _tokenId, uint256 nodeCreationTime) external onlyAuthorized {
require(_exists(_tokenId), "token not found");
address tokenOwner = ownerOf(_tokenId);
require(tokenOwner == account, "not owner");
Molecule memory mol = allMolecules[_tokenId];
require(mol.bonded == false, "Molecule already bonded");
mol.bonded = true;
allMolecules[_tokenId] = mol;
emit moleculeBonded(_tokenId, account, nodeCreationTime);
}
function unbondMolecule(address account,uint256 _tokenId, uint256 nodeCreationTime) external onlyAuthorized {
require(_exists(_tokenId), "token not found");
address tokenOwner = ownerOf(_tokenId);
require(tokenOwner == account, "not owner");
Molecule memory mol = allMolecules[_tokenId];
require(mol.bonded == true, "Molecule not bonded");
require(mol.bondedTime + unbondingTime > block.timestamp, "You have to wait 7 days from bonding to unbond");
mol.bonded = false;
allMolecules[_tokenId] = mol;
emit moleculeUnbonded(_tokenId, account, nodeCreationTime);
}
function growMolecule(uint256 _tokenId) external onlyAuthorized {
require(_exists(_tokenId), "token not found");
Molecule memory mol = allMolecules[_tokenId];
mol.level += 1;
allMolecules[_tokenId] = mol;
emit moleculeGrown(_tokenId, mol.level);
}
function getMoleculeLevel(uint256 _tokenId) public view returns(uint256){
Molecule memory mol = allMolecules[_tokenId];
return mol.level;
}
function getMoleculeKind(uint256 _tokenId) public view returns(uint256) {
Molecule memory mol = allMolecules[_tokenId];
return mol.kind;
}
//function to return all the structure data.
} | bondMolecule | function bondMolecule(address account,uint256 _tokenId, uint256 nodeCreationTime) external onlyAuthorized {
require(_exists(_tokenId), "token not found");
address tokenOwner = ownerOf(_tokenId);
require(tokenOwner == account, "not owner");
Molecule memory mol = allMolecules[_tokenId];
require(mol.bonded == false, "Molecule already bonded");
mol.bonded = true;
allMolecules[_tokenId] = mol;
emit moleculeBonded(_tokenId, account, nodeCreationTime);
}
| // upgrade contract to allow OXG Nodes to | LineComment | v0.8.7+commit.e28d00a7 | None | ipfs://20decf58842156897d98ab79d984540e98d9dc9d52eab19bc329196766f161a1 | {
"func_code_index": [
12914,
13447
]
} | 3,573 |
||
Gamblr | Gamblr.sol | 0x2224e74ca3c8b21f5ac916717e5abcc01d99c55b | Solidity | Ownable | contract Ownable {
address public owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev The Ownable constructor sets the original `owner` of the contract to the sender
* account.
*/
constructor() public {
owner = msg.sender;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(msg.sender == owner);
_;
}
/**
* @dev Allows the current owner to transfer control of the contract to a newOwner.
* @param newOwner The address to transfer ownership to.
*/
function transferOwnership(address newOwner) public onlyOwner {
require(newOwner != address(0));
emit OwnershipTransferred(owner, newOwner);
owner = newOwner;
}
} | /**
* @title Ownable
* @dev The Ownable contract has an owner address, and provides basic authorization control
* functions, this simplifies the implementation of "user permissions".
*/ | NatSpecMultiLine | transferOwnership | function transferOwnership(address newOwner) public onlyOwner {
require(newOwner != address(0));
emit OwnershipTransferred(owner, newOwner);
owner = newOwner;
}
| /**
* @dev Allows the current owner to transfer control of the contract to a newOwner.
* @param newOwner The address to transfer ownership to.
*/ | NatSpecMultiLine | v0.4.24+commit.e67f0147 | bzzr://006281bf94709051d36461c755688a9e8224b302a053fe882ebaa5205eb76fb0 | {
"func_code_index": [
673,
870
]
} | 3,574 |
|
Gamblr | Gamblr.sol | 0x2224e74ca3c8b21f5ac916717e5abcc01d99c55b | Solidity | SafeMath | library SafeMath {
/**
* @dev Multiplies two numbers, throws on overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
if (a == 0) {
return 0;
}
uint256 c = a * b;
assert(c / a == b);
return c;
}
/**
* @dev Integer division of two numbers, truncating the quotient.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
// assert(b > 0); // Solidity automatically throws 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, throws on overflow (i.e. if subtrahend is greater than minuend).
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
assert(b <= a);
return a - b;
}
/**
* @dev Adds two numbers, throws on overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
assert(c >= a);
return c;
}
} | /**
* @title SafeMath
* @dev Math operations with safety checks that throw on error
*/ | NatSpecMultiLine | mul | function mul(uint256 a, uint256 b) internal pure returns (uint256) {
if (a == 0) {
return 0;
}
uint256 c = a * b;
assert(c / a == b);
return c;
}
| /**
* @dev Multiplies two numbers, throws on overflow.
*/ | NatSpecMultiLine | v0.4.24+commit.e67f0147 | bzzr://006281bf94709051d36461c755688a9e8224b302a053fe882ebaa5205eb76fb0 | {
"func_code_index": [
89,
272
]
} | 3,575 |
|
Gamblr | Gamblr.sol | 0x2224e74ca3c8b21f5ac916717e5abcc01d99c55b | Solidity | SafeMath | library SafeMath {
/**
* @dev Multiplies two numbers, throws on overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
if (a == 0) {
return 0;
}
uint256 c = a * b;
assert(c / a == b);
return c;
}
/**
* @dev Integer division of two numbers, truncating the quotient.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
// assert(b > 0); // Solidity automatically throws 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, throws on overflow (i.e. if subtrahend is greater than minuend).
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
assert(b <= a);
return a - b;
}
/**
* @dev Adds two numbers, throws on overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
assert(c >= a);
return c;
}
} | /**
* @title SafeMath
* @dev Math operations with safety checks that throw on error
*/ | NatSpecMultiLine | div | function div(uint256 a, uint256 b) internal pure returns (uint256) {
// assert(b > 0); // Solidity automatically throws 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.
*/ | NatSpecMultiLine | v0.4.24+commit.e67f0147 | bzzr://006281bf94709051d36461c755688a9e8224b302a053fe882ebaa5205eb76fb0 | {
"func_code_index": [
356,
629
]
} | 3,576 |
|
Gamblr | Gamblr.sol | 0x2224e74ca3c8b21f5ac916717e5abcc01d99c55b | Solidity | SafeMath | library SafeMath {
/**
* @dev Multiplies two numbers, throws on overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
if (a == 0) {
return 0;
}
uint256 c = a * b;
assert(c / a == b);
return c;
}
/**
* @dev Integer division of two numbers, truncating the quotient.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
// assert(b > 0); // Solidity automatically throws 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, throws on overflow (i.e. if subtrahend is greater than minuend).
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
assert(b <= a);
return a - b;
}
/**
* @dev Adds two numbers, throws on overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
assert(c >= a);
return c;
}
} | /**
* @title SafeMath
* @dev Math operations with safety checks that throw on error
*/ | NatSpecMultiLine | sub | function sub(uint256 a, uint256 b) internal pure returns (uint256) {
assert(b <= a);
return a - b;
}
| /**
* @dev Subtracts two numbers, throws on overflow (i.e. if subtrahend is greater than minuend).
*/ | NatSpecMultiLine | v0.4.24+commit.e67f0147 | bzzr://006281bf94709051d36461c755688a9e8224b302a053fe882ebaa5205eb76fb0 | {
"func_code_index": [
743,
859
]
} | 3,577 |
|
Gamblr | Gamblr.sol | 0x2224e74ca3c8b21f5ac916717e5abcc01d99c55b | Solidity | SafeMath | library SafeMath {
/**
* @dev Multiplies two numbers, throws on overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
if (a == 0) {
return 0;
}
uint256 c = a * b;
assert(c / a == b);
return c;
}
/**
* @dev Integer division of two numbers, truncating the quotient.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
// assert(b > 0); // Solidity automatically throws 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, throws on overflow (i.e. if subtrahend is greater than minuend).
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
assert(b <= a);
return a - b;
}
/**
* @dev Adds two numbers, throws on overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
assert(c >= a);
return c;
}
} | /**
* @title SafeMath
* @dev Math operations with safety checks that throw on error
*/ | NatSpecMultiLine | add | function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
assert(c >= a);
return c;
}
| /**
* @dev Adds two numbers, throws on overflow.
*/ | NatSpecMultiLine | v0.4.24+commit.e67f0147 | bzzr://006281bf94709051d36461c755688a9e8224b302a053fe882ebaa5205eb76fb0 | {
"func_code_index": [
923,
1059
]
} | 3,578 |
|
AaveImport | contracts/mcd/saver/MCDSaverTaker.sol | 0x751961666d8605af1c5ee549205f822f47b04168 | Solidity | MCDSaverTaker | contract MCDSaverTaker is MCDSaverProxy, GasBurner {
address payable public constant MCD_SAVER_FLASH_LOAN = 0xD0eB57ff3eA4Def2b74dc29681fd529D1611880f;
address public constant AAVE_POOL_CORE = 0x3dfd23A6c5E8BbcFc9581d2E864a68feb6a076d3;
ILendingPool public constant lendingPool = ILendingPool(0x398eC7346DcD622eDc5ae82352F02bE94C62d119);
function boostWithLoan(
ExchangeData memory _exchangeData,
uint _cdpId,
uint _gasCost,
address _joinAddr
) public payable burnGas(25) {
uint256 maxDebt = getMaxDebt(_cdpId, manager.ilks(_cdpId));
uint maxLiq = getAvailableLiquidity(DAI_JOIN_ADDRESS);
if (maxDebt >= _exchangeData.srcAmount || maxLiq == 0) {
if (_exchangeData.srcAmount > maxDebt) {
_exchangeData.srcAmount = maxDebt;
}
boost(_exchangeData, _cdpId, _gasCost, _joinAddr);
return;
}
uint256 loanAmount = sub(_exchangeData.srcAmount, maxDebt);
loanAmount = loanAmount > maxLiq ? maxLiq : loanAmount;
MCD_SAVER_FLASH_LOAN.transfer(msg.value); // 0x fee
manager.cdpAllow(_cdpId, MCD_SAVER_FLASH_LOAN, 1);
bytes memory paramsData = abi.encode(packExchangeData(_exchangeData), _cdpId, _gasCost, _joinAddr, false);
lendingPool.flashLoan(MCD_SAVER_FLASH_LOAN, DAI_ADDRESS, loanAmount, paramsData);
manager.cdpAllow(_cdpId, MCD_SAVER_FLASH_LOAN, 0);
}
function repayWithLoan(
ExchangeData memory _exchangeData,
uint _cdpId,
uint _gasCost,
address _joinAddr
) public payable burnGas(25) {
uint256 maxColl = getMaxCollateral(_cdpId, manager.ilks(_cdpId), _joinAddr);
uint maxLiq = getAvailableLiquidity(_joinAddr);
if (maxColl >= _exchangeData.srcAmount || maxLiq == 0) {
if (_exchangeData.srcAmount > maxColl) {
_exchangeData.srcAmount = maxColl;
}
repay(_exchangeData, _cdpId, _gasCost, _joinAddr);
return;
}
uint256 loanAmount = sub(_exchangeData.srcAmount, maxColl);
loanAmount = loanAmount > maxLiq ? maxLiq : loanAmount;
MCD_SAVER_FLASH_LOAN.transfer(msg.value); // 0x fee
manager.cdpAllow(_cdpId, MCD_SAVER_FLASH_LOAN, 1);
bytes memory paramsData = abi.encode(packExchangeData(_exchangeData), _cdpId, _gasCost, _joinAddr, true);
lendingPool.flashLoan(MCD_SAVER_FLASH_LOAN, getAaveCollAddr(_joinAddr), loanAmount, paramsData);
manager.cdpAllow(_cdpId, MCD_SAVER_FLASH_LOAN, 0);
}
/// @notice Gets the maximum amount of debt available to generate
/// @param _cdpId Id of the CDP
/// @param _ilk Ilk of the CDP
function getMaxDebt(uint256 _cdpId, bytes32 _ilk) public override view returns (uint256) {
uint256 price = getPrice(_ilk);
(, uint256 mat) = spotter.ilks(_ilk);
(uint256 collateral, uint256 debt) = getCdpInfo(manager, _cdpId, _ilk);
return sub(wdiv(wmul(collateral, price), mat), debt);
}
function getAaveCollAddr(address _joinAddr) internal view returns (address) {
if (isEthJoinAddr(_joinAddr)
|| _joinAddr == 0x775787933e92b709f2a3C70aa87999696e74A9F8) {
return KYBER_ETH_ADDRESS;
} else if (_joinAddr == DAI_JOIN_ADDRESS) {
return DAI_ADDRESS;
} else
{
return getCollateralAddr(_joinAddr);
}
}
function getAvailableLiquidity(address _joinAddr) internal view returns (uint liquidity) {
address tokenAddr = getAaveCollAddr(_joinAddr);
if (tokenAddr == KYBER_ETH_ADDRESS) {
liquidity = AAVE_POOL_CORE.balance;
} else {
liquidity = ERC20(tokenAddr).balanceOf(AAVE_POOL_CORE);
}
}
} | // abstract contract ILendingPool {
// function flashLoan( address payable _receiver, address _reserve, uint _amount, bytes calldata _params) external virtual;
// } | LineComment | getMaxDebt | function getMaxDebt(uint256 _cdpId, bytes32 _ilk) public override view returns (uint256) {
uint256 price = getPrice(_ilk);
(, uint256 mat) = spotter.ilks(_ilk);
(uint256 collateral, uint256 debt) = getCdpInfo(manager, _cdpId, _ilk);
return sub(wdiv(wmul(collateral, price), mat), debt);
}
| /// @notice Gets the maximum amount of debt available to generate
/// @param _cdpId Id of the CDP
/// @param _ilk Ilk of the CDP | NatSpecSingleLine | v0.6.12+commit.27d51765 | MIT | ipfs://34c42220a035234e7357a4f4dce033d4f7741dd29565a8d77139b7fde50d3c09 | {
"func_code_index": [
2748,
3078
]
} | 3,579 |
Stealth | Stealth.sol | 0x00000000f2cfa550ad4aae0f33bcaad5164900be | 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.
*/ | Comment | totalSupply | function totalSupply() external view returns (uint256);
| /**
* @dev Returns the amount of tokens in existence.
*/ | NatSpecMultiLine | v0.8.6+commit.11564f7e | None | ipfs://d19ce80d824c23f20ef23ce6fa9664081761593819659a6fbe6272b3a7dedce6 | {
"func_code_index": [
94,
154
]
} | 3,580 |
Stealth | Stealth.sol | 0x00000000f2cfa550ad4aae0f33bcaad5164900be | 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.
*/ | Comment | balanceOf | function balanceOf(address account) external view returns (uint256);
| /**
* @dev Returns the amount of tokens owned by `account`.
*/ | NatSpecMultiLine | v0.8.6+commit.11564f7e | None | ipfs://d19ce80d824c23f20ef23ce6fa9664081761593819659a6fbe6272b3a7dedce6 | {
"func_code_index": [
237,
310
]
} | 3,581 |
Stealth | Stealth.sol | 0x00000000f2cfa550ad4aae0f33bcaad5164900be | 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.
*/ | Comment | 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.6+commit.11564f7e | None | ipfs://d19ce80d824c23f20ef23ce6fa9664081761593819659a6fbe6272b3a7dedce6 | {
"func_code_index": [
534,
616
]
} | 3,582 |
Stealth | Stealth.sol | 0x00000000f2cfa550ad4aae0f33bcaad5164900be | 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.
*/ | Comment | 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.6+commit.11564f7e | None | ipfs://d19ce80d824c23f20ef23ce6fa9664081761593819659a6fbe6272b3a7dedce6 | {
"func_code_index": [
895,
983
]
} | 3,583 |
Stealth | Stealth.sol | 0x00000000f2cfa550ad4aae0f33bcaad5164900be | 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.
*/ | Comment | 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.6+commit.11564f7e | None | ipfs://d19ce80d824c23f20ef23ce6fa9664081761593819659a6fbe6272b3a7dedce6 | {
"func_code_index": [
1647,
1726
]
} | 3,584 |
Stealth | Stealth.sol | 0x00000000f2cfa550ad4aae0f33bcaad5164900be | 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.
*/ | Comment | 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.6+commit.11564f7e | None | ipfs://d19ce80d824c23f20ef23ce6fa9664081761593819659a6fbe6272b3a7dedce6 | {
"func_code_index": [
2039,
2175
]
} | 3,585 |
Stealth | Stealth.sol | 0x00000000f2cfa550ad4aae0f33bcaad5164900be | Solidity | Ownable | contract Ownable is Context {
address payable private _owner;
address payable private _previousOwner;
uint256 private _lockTime;
event OwnershipTransferred(
address indexed previousOwner,
address indexed newOwner
);
constructor() {
_owner = _msgSender();
emit OwnershipTransferred(address(0), _owner);
}
function owner() public view returns (address) {
return _owner;
}
modifier onlyOwner() {
require(_owner == _msgSender(), "Ownable: caller is not the owner");
_;
}
function renounceOwnership() public virtual onlyOwner {
emit OwnershipTransferred(_owner, address(0));
_owner = payable(address(0));
}
function transferOwnership(address payable newOwner)
public
virtual
onlyOwner
{
require(
newOwner != address(0),
"Ownable: new owner is the zero address"
);
emit OwnershipTransferred(_owner, newOwner);
_owner = newOwner;
}
function getUnlockTime() public view returns (uint256) {
return _lockTime;
}
//Locks the contract for owner for the amount of time provided
function lock(uint256 time) public virtual onlyOwner {
_previousOwner = _owner;
_owner = payable(address(0));
_lockTime = block.timestamp + time;
emit OwnershipTransferred(_owner, address(0));
}
//Unlocks the contract for owner when _lockTime is exceeds
function unlock() public virtual {
require(
_previousOwner == msg.sender,
"You don't have permission to unlock"
);
require(
block.timestamp > _lockTime,
"Contract is locked until defined days"
);
emit OwnershipTransferred(_owner, _previousOwner);
_owner = _previousOwner;
_previousOwner = payable(address(0));
}
} | lock | function lock(uint256 time) public virtual onlyOwner {
_previousOwner = _owner;
_owner = payable(address(0));
_lockTime = block.timestamp + time;
emit OwnershipTransferred(_owner, address(0));
}
| //Locks the contract for owner for the amount of time provided | LineComment | v0.8.6+commit.11564f7e | None | ipfs://d19ce80d824c23f20ef23ce6fa9664081761593819659a6fbe6272b3a7dedce6 | {
"func_code_index": [
1256,
1496
]
} | 3,586 |
||
Stealth | Stealth.sol | 0x00000000f2cfa550ad4aae0f33bcaad5164900be | Solidity | Ownable | contract Ownable is Context {
address payable private _owner;
address payable private _previousOwner;
uint256 private _lockTime;
event OwnershipTransferred(
address indexed previousOwner,
address indexed newOwner
);
constructor() {
_owner = _msgSender();
emit OwnershipTransferred(address(0), _owner);
}
function owner() public view returns (address) {
return _owner;
}
modifier onlyOwner() {
require(_owner == _msgSender(), "Ownable: caller is not the owner");
_;
}
function renounceOwnership() public virtual onlyOwner {
emit OwnershipTransferred(_owner, address(0));
_owner = payable(address(0));
}
function transferOwnership(address payable newOwner)
public
virtual
onlyOwner
{
require(
newOwner != address(0),
"Ownable: new owner is the zero address"
);
emit OwnershipTransferred(_owner, newOwner);
_owner = newOwner;
}
function getUnlockTime() public view returns (uint256) {
return _lockTime;
}
//Locks the contract for owner for the amount of time provided
function lock(uint256 time) public virtual onlyOwner {
_previousOwner = _owner;
_owner = payable(address(0));
_lockTime = block.timestamp + time;
emit OwnershipTransferred(_owner, address(0));
}
//Unlocks the contract for owner when _lockTime is exceeds
function unlock() public virtual {
require(
_previousOwner == msg.sender,
"You don't have permission to unlock"
);
require(
block.timestamp > _lockTime,
"Contract is locked until defined days"
);
emit OwnershipTransferred(_owner, _previousOwner);
_owner = _previousOwner;
_previousOwner = payable(address(0));
}
} | unlock | function unlock() public virtual {
require(
_previousOwner == msg.sender,
"You don't have permission to unlock"
);
require(
block.timestamp > _lockTime,
"Contract is locked until defined days"
);
emit OwnershipTransferred(_owner, _previousOwner);
_owner = _previousOwner;
_previousOwner = payable(address(0));
}
| //Unlocks the contract for owner when _lockTime is exceeds | LineComment | v0.8.6+commit.11564f7e | None | ipfs://d19ce80d824c23f20ef23ce6fa9664081761593819659a6fbe6272b3a7dedce6 | {
"func_code_index": [
1563,
1999
]
} | 3,587 |
||
Stealth | Stealth.sol | 0x00000000f2cfa550ad4aae0f33bcaad5164900be | Solidity | Stealth | contract Stealth is Context, IERC20, Ownable {
using SafeMath for uint256;
// If you are reading this then welcome - this is where the work happens.
// StealthStandard Check
mapping (address => uint256) private _balances;
mapping (address => uint256) private _firstBuy;
mapping (address => uint256) private _lastBuy;
mapping (address => uint256) private _lastSell;
mapping (address => mapping (address => uint256)) private _allowances;
mapping (address => bool) private _isExcludedFromFee;
mapping (address => bool) private _hasTraded;
mapping (address => bool) private bots;
mapping (address => uint) private cooldown;
uint256 private constant _tTotal = 1000000000000 * 10**18;
uint256 private _tradingStartTimestamp;
uint256 public sellCoolDownTime = 60 seconds;
uint256 private minTokensToSell = _tTotal.div(100000);
address payable private _stealthMultiSigWallet;
string private constant _name = "Stealth Standard";
string private constant _symbol = "$STEALTH";
uint8 private constant _decimals = 18;
IUniswapV2Router02 public uniswapV2Router;
address public uniswapV2Pair;
bool private tradingOpen = false;
bool private inSwap = false;
bool private swapEnabled = false;
bool private antiBotEnabled = false;
modifier lockTheSwap {
inSwap = true;
_;
inSwap = false;
}
constructor () {
_stealthMultiSigWallet = payable(0x852a8cb5D5e09133EDa0713C1A475A5B7dE80226);
IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D);
address _uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory()).createPair(address(this), _uniswapV2Router.WETH());
uniswapV2Router = _uniswapV2Router;
uniswapV2Pair = _uniswapV2Pair;
_balances[_msgSender()] = _tTotal;
_isExcludedFromFee[owner()] = true;
_isExcludedFromFee[address(this)] = true;
_isExcludedFromFee[_stealthMultiSigWallet] = true;
emit Transfer(address(0), _msgSender(), _tTotal);
}
function name() public pure returns (string memory) {
return _name;
}
function symbol() public pure returns (string memory) {
return _symbol;
}
function decimals() public pure returns (uint8) {
return _decimals;
}
function totalSupply() public pure override returns (uint256) {
return _tTotal;
}
function balanceOf(address account) public view override returns (uint256) {
return _balances[account];
}
function transfer(address recipient, uint256 amount) public override returns (bool) {
_transfer(_msgSender(), recipient, amount);
return true;
}
function allowance(address owner, address spender) public view override returns (uint256) {
return _allowances[owner][spender];
}
function approve(address spender, uint256 amount) public override returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) {
_transfer(sender, recipient, amount);
_approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance"));
return true;
}
function _approve(address owner, address spender, uint256 amount) private {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
function _transfer(address from, address to, uint256 amount) private {
require(from != address(0), "ERC20: transfer from the zero address");
require(to != address(0), "ERC20: transfer to the zero address");
require(amount > 0, "Transfer amount must be greater than zero");
require(balanceOf(from) >= amount,"Not enough balance for tx");
// Check if we are buying or selling, or simply transferring
//if (to == uniswapV2Pair && from != address(uniswapV2Router) && from != owner() && from != address(this) && ! _isExcludedFromFee[from]) {
if ((to == uniswapV2Pair) && ! _isExcludedFromFee[from]) {
// Selling to uniswapV2Pair:
// ensure trading is open
require(tradingOpen,"trading is not yet open");
// Block known bots from selling - If you think this was a mistake please contact the Stealth Team
require(!bots[from], "Stealth is a Bot Free Zone");
// anti bot code - checks for buys and sells in the same block or within the sellCoolDownTime
if (antiBotEnabled) {
uint256 lastBuy = _lastBuy[from];
require(block.timestamp > lastBuy, "Sorry - no FrontRunning allowed right now");
require(cooldown[from] < block.timestamp);
cooldown[from] = block.timestamp + sellCoolDownTime;
}
// Has Seller made a trade before? If not set to current block timestamp
// We check this again on a sell to make sure they didn't transfer to a new wallet
if (!_hasTraded[from]){
_firstBuy[from] = block.timestamp;
_hasTraded[from] = true;
}
if (swapEnabled) {
// handle sell of tokens in contract for Eth
uint256 contractTokenBalance = balanceOf(address(this));
if (contractTokenBalance >= minTokensToSell) {
if (!inSwap) {
swapTokensForEth(contractTokenBalance);
uint256 contractETHBalance = address(this).balance;
if(contractETHBalance > 0) {
sendETHToWallet(address(this).balance);
}
}
}
}
// Check to see if just taking profits or selling over 5%
bool justTakingProfits = _justTakingProfits(amount, from);
uint256 numHours = _getHours(_lastSell[from], block.timestamp);
uint256 numDays = (numHours / 24);
if (justTakingProfits) {
// just taking profits but need to make sure its been more than 7 days since last sell if so
if (numDays < 7) {
_firstBuy[from] = block.timestamp;
_lastBuy[from] = block.timestamp;
}
} else {
if (numDays < 84) {
// sold over 5% so we reset the last buy to be now
_firstBuy[from] = block.timestamp;
_lastBuy[from] = block.timestamp;
}
}
// Record last sell timestamp
_lastSell[from] = block.timestamp;
// Transfer with taxes
_tokenTransferTaxed(from,to,amount);
//} else if (from == uniswapV2Pair && to != address(uniswapV2Router) && to != owner() && to != address(this)) {
} else if ((from == uniswapV2Pair) && ! _isExcludedFromFee[to]) {
// Buying from uniswapV2Pair:
// ensure trading is open
require(tradingOpen,"trading is not yet open");
// Has buyer made a trade before? If not set to current block timestamp
if (!_hasTraded[to]){
_firstBuy[to] = block.timestamp;
_hasTraded[to] = true;
}
// snapshot the last buy timestamp
_lastBuy[to] = block.timestamp;
// Simple Transfer with no taxes
_transferFree(from, to, amount);
} else {
// Other transfer
// Block known bots from selling - If you think this was a mistake please contact the Stealth Team
require(!bots[from] && !bots[to], "Stealth is a Bot Free Zone");
// Handle the case of wallet to wallet transfer
_firstBuy[to] = block.timestamp;
_hasTraded[to] = true;
// Simple Transfer with no taxes
_transferFree(from, to, amount);
}
}
function swapTokensForEth(uint256 tokenAmount) private lockTheSwap {
address[] memory path = new address[](2);
path[0] = address(this);
path[1] = uniswapV2Router.WETH();
_approve(address(this), address(uniswapV2Router), tokenAmount);
uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens(
tokenAmount,
0,
path,
address(this),
block.timestamp
);
}
// If we are doing a tax free Transfer that happens here after _transfer:
function _transferFree(address sender, address recipient, uint256 tAmount) private {
_balances[sender] = _balances[sender].sub(tAmount);
_balances[recipient] = _balances[recipient].add(tAmount);
emit Transfer(sender, recipient, tAmount);
}
// If we are doing a taxed Transfer that happens here after _transfer:
function _tokenTransferTaxed(address sender, address recipient, uint256 amount) private {
_transferTaxed(sender, recipient, amount);
}
function _transferTaxed(address sender, address recipient, uint256 tAmount) private {
// Calculate the taxed token amount
uint256 tTeam = _getTaxedValue(tAmount, sender);
uint256 transferAmount = tAmount - tTeam;
_balances[sender] = _balances[sender].sub(tAmount);
_balances[recipient] = _balances[recipient].add(transferAmount);
_takeTeam(tTeam);
emit Transfer(sender, recipient, transferAmount);
}
function _takeTeam(uint256 tTeam) private {
_balances[address(this)] = _balances[address(this)].add(tTeam);
}
// Check to see if the sell amount is greater than 5% of tokens in a 7 day period
function _justTakingProfits(uint256 sellAmount, address account) private view returns(bool) {
// Basic cheak to see if we are selling more than 5% - if so return false
if ((sellAmount * 20) > _balances[account]) {
return false;
} else {
return true;
}
}
// Calculate the number of taxed tokens for a transaction
function _getTaxedValue(uint256 transTokens, address account) private view returns(uint256){
uint256 taxRate = _getTaxRate(account);
if (taxRate == 0) {
return 0;
} else {
uint256 numerator = (transTokens * (10000 - (100 * taxRate)));
return (((transTokens * 10000) - numerator) / 10000);
}
}
// Calculate the current tax rate.
function _getTaxRate(address account) private view returns(uint256) {
uint256 numHours = _getHours(_tradingStartTimestamp, block.timestamp);
if (numHours <= 24){
// 20% Sell Tax first 24 Hours
return 20;
} else if (numHours <= 48){
// 16% Sell Tax second 24 Hours
return 16;
} else {
// 12% Sell Tax starting rate
numHours = _getHours(_firstBuy[account], block.timestamp);
uint256 numDays = (numHours / 24);
if (numDays >= 84 ){
//12 x 7 = 84 = tax free!
return 0;
} else {
uint256 numWeeks = (numDays / 7);
return (12 - numWeeks);
}
}
}
// Calculate the number of hours that have passed between endDate and startDate:
function _getHours(uint256 startDate, uint256 endDate) private pure returns(uint256){
return ((endDate - startDate) / 60 / 60);
}
receive() external payable {}
function manualswap() external {
require(_msgSender() == _stealthMultiSigWallet || _msgSender() == address(this) || _msgSender() == owner());
uint256 contractBalance = balanceOf(address(this));
swapTokensForEth(contractBalance);
}
function manualsend() external {
require(_msgSender() == _stealthMultiSigWallet || _msgSender() == address(this) || _msgSender() == owner());
uint256 contractETHBalance = address(this).balance;
sendETHToWallet(contractETHBalance);
}
function airdrop(address[] memory _user, uint256[] memory _amount) external onlyOwner {
uint256 len = _user.length;
require(len == _amount.length);
for (uint256 i = 0; i < len; i++) {
_balances[_msgSender()] = _balances[_msgSender()].sub(_amount[i], "ERC20: transfer amount exceeds balance");
_balances[_user[i]] = _balances[_user[i]].add(_amount[i]);
emit Transfer(_msgSender(), _user[i], _amount[i]);
}
}
function setMultipleBots(address[] memory bots_) public onlyOwner {
for (uint i = 0; i < bots_.length; i++) {
bots[bots_[i]] = true;
}
}
function setBot(address isbot) public onlyOwner {
bots[isbot] = true;
}
function deleteBot(address notbot) public onlyOwner {
bots[notbot] = false;
}
function isBlacklisted(address isbot) public view returns(bool) {
return bots[isbot];
}
function setAntiBotMode(bool onoff) external onlyOwner() {
antiBotEnabled = onoff;
}
function isAntiBotEnabled() public view returns(bool) {
return antiBotEnabled;
}
function excludeFromFee(address account) public onlyOwner {
_isExcludedFromFee[account] = true;
}
function includeInFee(address account) public onlyOwner {
_isExcludedFromFee[account] = false;
}
function setSellCoolDownTime(uint256 _newTime) public onlyOwner {
sellCoolDownTime = _newTime;
}
function updateRouter(IUniswapV2Router02 newRouter, address newPair) external onlyOwner {
uniswapV2Router = newRouter;
uniswapV2Pair = newPair;
}
function sendETHToWallet(uint256 amount) private {
_stealthMultiSigWallet.transfer(amount);
}
function startTrading() external onlyOwner() {
require(!tradingOpen,"trading is already open");
antiBotEnabled = true;
swapEnabled = true;
tradingOpen = true;
_tradingStartTimestamp = block.timestamp;
}
function setSwapEnabledMode(bool swap) external onlyOwner {
swapEnabled = swap;
}
function isTradingOpen() public view returns(bool) {
return tradingOpen;
}
} | _transferFree | function _transferFree(address sender, address recipient, uint256 tAmount) private {
_balances[sender] = _balances[sender].sub(tAmount);
_balances[recipient] = _balances[recipient].add(tAmount);
emit Transfer(sender, recipient, tAmount);
}
| // If we are doing a tax free Transfer that happens here after _transfer: | LineComment | v0.8.6+commit.11564f7e | None | ipfs://d19ce80d824c23f20ef23ce6fa9664081761593819659a6fbe6272b3a7dedce6 | {
"func_code_index": [
9088,
9365
]
} | 3,588 |
||
Stealth | Stealth.sol | 0x00000000f2cfa550ad4aae0f33bcaad5164900be | Solidity | Stealth | contract Stealth is Context, IERC20, Ownable {
using SafeMath for uint256;
// If you are reading this then welcome - this is where the work happens.
// StealthStandard Check
mapping (address => uint256) private _balances;
mapping (address => uint256) private _firstBuy;
mapping (address => uint256) private _lastBuy;
mapping (address => uint256) private _lastSell;
mapping (address => mapping (address => uint256)) private _allowances;
mapping (address => bool) private _isExcludedFromFee;
mapping (address => bool) private _hasTraded;
mapping (address => bool) private bots;
mapping (address => uint) private cooldown;
uint256 private constant _tTotal = 1000000000000 * 10**18;
uint256 private _tradingStartTimestamp;
uint256 public sellCoolDownTime = 60 seconds;
uint256 private minTokensToSell = _tTotal.div(100000);
address payable private _stealthMultiSigWallet;
string private constant _name = "Stealth Standard";
string private constant _symbol = "$STEALTH";
uint8 private constant _decimals = 18;
IUniswapV2Router02 public uniswapV2Router;
address public uniswapV2Pair;
bool private tradingOpen = false;
bool private inSwap = false;
bool private swapEnabled = false;
bool private antiBotEnabled = false;
modifier lockTheSwap {
inSwap = true;
_;
inSwap = false;
}
constructor () {
_stealthMultiSigWallet = payable(0x852a8cb5D5e09133EDa0713C1A475A5B7dE80226);
IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D);
address _uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory()).createPair(address(this), _uniswapV2Router.WETH());
uniswapV2Router = _uniswapV2Router;
uniswapV2Pair = _uniswapV2Pair;
_balances[_msgSender()] = _tTotal;
_isExcludedFromFee[owner()] = true;
_isExcludedFromFee[address(this)] = true;
_isExcludedFromFee[_stealthMultiSigWallet] = true;
emit Transfer(address(0), _msgSender(), _tTotal);
}
function name() public pure returns (string memory) {
return _name;
}
function symbol() public pure returns (string memory) {
return _symbol;
}
function decimals() public pure returns (uint8) {
return _decimals;
}
function totalSupply() public pure override returns (uint256) {
return _tTotal;
}
function balanceOf(address account) public view override returns (uint256) {
return _balances[account];
}
function transfer(address recipient, uint256 amount) public override returns (bool) {
_transfer(_msgSender(), recipient, amount);
return true;
}
function allowance(address owner, address spender) public view override returns (uint256) {
return _allowances[owner][spender];
}
function approve(address spender, uint256 amount) public override returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) {
_transfer(sender, recipient, amount);
_approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance"));
return true;
}
function _approve(address owner, address spender, uint256 amount) private {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
function _transfer(address from, address to, uint256 amount) private {
require(from != address(0), "ERC20: transfer from the zero address");
require(to != address(0), "ERC20: transfer to the zero address");
require(amount > 0, "Transfer amount must be greater than zero");
require(balanceOf(from) >= amount,"Not enough balance for tx");
// Check if we are buying or selling, or simply transferring
//if (to == uniswapV2Pair && from != address(uniswapV2Router) && from != owner() && from != address(this) && ! _isExcludedFromFee[from]) {
if ((to == uniswapV2Pair) && ! _isExcludedFromFee[from]) {
// Selling to uniswapV2Pair:
// ensure trading is open
require(tradingOpen,"trading is not yet open");
// Block known bots from selling - If you think this was a mistake please contact the Stealth Team
require(!bots[from], "Stealth is a Bot Free Zone");
// anti bot code - checks for buys and sells in the same block or within the sellCoolDownTime
if (antiBotEnabled) {
uint256 lastBuy = _lastBuy[from];
require(block.timestamp > lastBuy, "Sorry - no FrontRunning allowed right now");
require(cooldown[from] < block.timestamp);
cooldown[from] = block.timestamp + sellCoolDownTime;
}
// Has Seller made a trade before? If not set to current block timestamp
// We check this again on a sell to make sure they didn't transfer to a new wallet
if (!_hasTraded[from]){
_firstBuy[from] = block.timestamp;
_hasTraded[from] = true;
}
if (swapEnabled) {
// handle sell of tokens in contract for Eth
uint256 contractTokenBalance = balanceOf(address(this));
if (contractTokenBalance >= minTokensToSell) {
if (!inSwap) {
swapTokensForEth(contractTokenBalance);
uint256 contractETHBalance = address(this).balance;
if(contractETHBalance > 0) {
sendETHToWallet(address(this).balance);
}
}
}
}
// Check to see if just taking profits or selling over 5%
bool justTakingProfits = _justTakingProfits(amount, from);
uint256 numHours = _getHours(_lastSell[from], block.timestamp);
uint256 numDays = (numHours / 24);
if (justTakingProfits) {
// just taking profits but need to make sure its been more than 7 days since last sell if so
if (numDays < 7) {
_firstBuy[from] = block.timestamp;
_lastBuy[from] = block.timestamp;
}
} else {
if (numDays < 84) {
// sold over 5% so we reset the last buy to be now
_firstBuy[from] = block.timestamp;
_lastBuy[from] = block.timestamp;
}
}
// Record last sell timestamp
_lastSell[from] = block.timestamp;
// Transfer with taxes
_tokenTransferTaxed(from,to,amount);
//} else if (from == uniswapV2Pair && to != address(uniswapV2Router) && to != owner() && to != address(this)) {
} else if ((from == uniswapV2Pair) && ! _isExcludedFromFee[to]) {
// Buying from uniswapV2Pair:
// ensure trading is open
require(tradingOpen,"trading is not yet open");
// Has buyer made a trade before? If not set to current block timestamp
if (!_hasTraded[to]){
_firstBuy[to] = block.timestamp;
_hasTraded[to] = true;
}
// snapshot the last buy timestamp
_lastBuy[to] = block.timestamp;
// Simple Transfer with no taxes
_transferFree(from, to, amount);
} else {
// Other transfer
// Block known bots from selling - If you think this was a mistake please contact the Stealth Team
require(!bots[from] && !bots[to], "Stealth is a Bot Free Zone");
// Handle the case of wallet to wallet transfer
_firstBuy[to] = block.timestamp;
_hasTraded[to] = true;
// Simple Transfer with no taxes
_transferFree(from, to, amount);
}
}
function swapTokensForEth(uint256 tokenAmount) private lockTheSwap {
address[] memory path = new address[](2);
path[0] = address(this);
path[1] = uniswapV2Router.WETH();
_approve(address(this), address(uniswapV2Router), tokenAmount);
uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens(
tokenAmount,
0,
path,
address(this),
block.timestamp
);
}
// If we are doing a tax free Transfer that happens here after _transfer:
function _transferFree(address sender, address recipient, uint256 tAmount) private {
_balances[sender] = _balances[sender].sub(tAmount);
_balances[recipient] = _balances[recipient].add(tAmount);
emit Transfer(sender, recipient, tAmount);
}
// If we are doing a taxed Transfer that happens here after _transfer:
function _tokenTransferTaxed(address sender, address recipient, uint256 amount) private {
_transferTaxed(sender, recipient, amount);
}
function _transferTaxed(address sender, address recipient, uint256 tAmount) private {
// Calculate the taxed token amount
uint256 tTeam = _getTaxedValue(tAmount, sender);
uint256 transferAmount = tAmount - tTeam;
_balances[sender] = _balances[sender].sub(tAmount);
_balances[recipient] = _balances[recipient].add(transferAmount);
_takeTeam(tTeam);
emit Transfer(sender, recipient, transferAmount);
}
function _takeTeam(uint256 tTeam) private {
_balances[address(this)] = _balances[address(this)].add(tTeam);
}
// Check to see if the sell amount is greater than 5% of tokens in a 7 day period
function _justTakingProfits(uint256 sellAmount, address account) private view returns(bool) {
// Basic cheak to see if we are selling more than 5% - if so return false
if ((sellAmount * 20) > _balances[account]) {
return false;
} else {
return true;
}
}
// Calculate the number of taxed tokens for a transaction
function _getTaxedValue(uint256 transTokens, address account) private view returns(uint256){
uint256 taxRate = _getTaxRate(account);
if (taxRate == 0) {
return 0;
} else {
uint256 numerator = (transTokens * (10000 - (100 * taxRate)));
return (((transTokens * 10000) - numerator) / 10000);
}
}
// Calculate the current tax rate.
function _getTaxRate(address account) private view returns(uint256) {
uint256 numHours = _getHours(_tradingStartTimestamp, block.timestamp);
if (numHours <= 24){
// 20% Sell Tax first 24 Hours
return 20;
} else if (numHours <= 48){
// 16% Sell Tax second 24 Hours
return 16;
} else {
// 12% Sell Tax starting rate
numHours = _getHours(_firstBuy[account], block.timestamp);
uint256 numDays = (numHours / 24);
if (numDays >= 84 ){
//12 x 7 = 84 = tax free!
return 0;
} else {
uint256 numWeeks = (numDays / 7);
return (12 - numWeeks);
}
}
}
// Calculate the number of hours that have passed between endDate and startDate:
function _getHours(uint256 startDate, uint256 endDate) private pure returns(uint256){
return ((endDate - startDate) / 60 / 60);
}
receive() external payable {}
function manualswap() external {
require(_msgSender() == _stealthMultiSigWallet || _msgSender() == address(this) || _msgSender() == owner());
uint256 contractBalance = balanceOf(address(this));
swapTokensForEth(contractBalance);
}
function manualsend() external {
require(_msgSender() == _stealthMultiSigWallet || _msgSender() == address(this) || _msgSender() == owner());
uint256 contractETHBalance = address(this).balance;
sendETHToWallet(contractETHBalance);
}
function airdrop(address[] memory _user, uint256[] memory _amount) external onlyOwner {
uint256 len = _user.length;
require(len == _amount.length);
for (uint256 i = 0; i < len; i++) {
_balances[_msgSender()] = _balances[_msgSender()].sub(_amount[i], "ERC20: transfer amount exceeds balance");
_balances[_user[i]] = _balances[_user[i]].add(_amount[i]);
emit Transfer(_msgSender(), _user[i], _amount[i]);
}
}
function setMultipleBots(address[] memory bots_) public onlyOwner {
for (uint i = 0; i < bots_.length; i++) {
bots[bots_[i]] = true;
}
}
function setBot(address isbot) public onlyOwner {
bots[isbot] = true;
}
function deleteBot(address notbot) public onlyOwner {
bots[notbot] = false;
}
function isBlacklisted(address isbot) public view returns(bool) {
return bots[isbot];
}
function setAntiBotMode(bool onoff) external onlyOwner() {
antiBotEnabled = onoff;
}
function isAntiBotEnabled() public view returns(bool) {
return antiBotEnabled;
}
function excludeFromFee(address account) public onlyOwner {
_isExcludedFromFee[account] = true;
}
function includeInFee(address account) public onlyOwner {
_isExcludedFromFee[account] = false;
}
function setSellCoolDownTime(uint256 _newTime) public onlyOwner {
sellCoolDownTime = _newTime;
}
function updateRouter(IUniswapV2Router02 newRouter, address newPair) external onlyOwner {
uniswapV2Router = newRouter;
uniswapV2Pair = newPair;
}
function sendETHToWallet(uint256 amount) private {
_stealthMultiSigWallet.transfer(amount);
}
function startTrading() external onlyOwner() {
require(!tradingOpen,"trading is already open");
antiBotEnabled = true;
swapEnabled = true;
tradingOpen = true;
_tradingStartTimestamp = block.timestamp;
}
function setSwapEnabledMode(bool swap) external onlyOwner {
swapEnabled = swap;
}
function isTradingOpen() public view returns(bool) {
return tradingOpen;
}
} | _tokenTransferTaxed | function _tokenTransferTaxed(address sender, address recipient, uint256 amount) private {
_transferTaxed(sender, recipient, amount);
}
| // If we are doing a taxed Transfer that happens here after _transfer: | LineComment | v0.8.6+commit.11564f7e | None | ipfs://d19ce80d824c23f20ef23ce6fa9664081761593819659a6fbe6272b3a7dedce6 | {
"func_code_index": [
9452,
9605
]
} | 3,589 |
||
Stealth | Stealth.sol | 0x00000000f2cfa550ad4aae0f33bcaad5164900be | Solidity | Stealth | contract Stealth is Context, IERC20, Ownable {
using SafeMath for uint256;
// If you are reading this then welcome - this is where the work happens.
// StealthStandard Check
mapping (address => uint256) private _balances;
mapping (address => uint256) private _firstBuy;
mapping (address => uint256) private _lastBuy;
mapping (address => uint256) private _lastSell;
mapping (address => mapping (address => uint256)) private _allowances;
mapping (address => bool) private _isExcludedFromFee;
mapping (address => bool) private _hasTraded;
mapping (address => bool) private bots;
mapping (address => uint) private cooldown;
uint256 private constant _tTotal = 1000000000000 * 10**18;
uint256 private _tradingStartTimestamp;
uint256 public sellCoolDownTime = 60 seconds;
uint256 private minTokensToSell = _tTotal.div(100000);
address payable private _stealthMultiSigWallet;
string private constant _name = "Stealth Standard";
string private constant _symbol = "$STEALTH";
uint8 private constant _decimals = 18;
IUniswapV2Router02 public uniswapV2Router;
address public uniswapV2Pair;
bool private tradingOpen = false;
bool private inSwap = false;
bool private swapEnabled = false;
bool private antiBotEnabled = false;
modifier lockTheSwap {
inSwap = true;
_;
inSwap = false;
}
constructor () {
_stealthMultiSigWallet = payable(0x852a8cb5D5e09133EDa0713C1A475A5B7dE80226);
IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D);
address _uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory()).createPair(address(this), _uniswapV2Router.WETH());
uniswapV2Router = _uniswapV2Router;
uniswapV2Pair = _uniswapV2Pair;
_balances[_msgSender()] = _tTotal;
_isExcludedFromFee[owner()] = true;
_isExcludedFromFee[address(this)] = true;
_isExcludedFromFee[_stealthMultiSigWallet] = true;
emit Transfer(address(0), _msgSender(), _tTotal);
}
function name() public pure returns (string memory) {
return _name;
}
function symbol() public pure returns (string memory) {
return _symbol;
}
function decimals() public pure returns (uint8) {
return _decimals;
}
function totalSupply() public pure override returns (uint256) {
return _tTotal;
}
function balanceOf(address account) public view override returns (uint256) {
return _balances[account];
}
function transfer(address recipient, uint256 amount) public override returns (bool) {
_transfer(_msgSender(), recipient, amount);
return true;
}
function allowance(address owner, address spender) public view override returns (uint256) {
return _allowances[owner][spender];
}
function approve(address spender, uint256 amount) public override returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) {
_transfer(sender, recipient, amount);
_approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance"));
return true;
}
function _approve(address owner, address spender, uint256 amount) private {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
function _transfer(address from, address to, uint256 amount) private {
require(from != address(0), "ERC20: transfer from the zero address");
require(to != address(0), "ERC20: transfer to the zero address");
require(amount > 0, "Transfer amount must be greater than zero");
require(balanceOf(from) >= amount,"Not enough balance for tx");
// Check if we are buying or selling, or simply transferring
//if (to == uniswapV2Pair && from != address(uniswapV2Router) && from != owner() && from != address(this) && ! _isExcludedFromFee[from]) {
if ((to == uniswapV2Pair) && ! _isExcludedFromFee[from]) {
// Selling to uniswapV2Pair:
// ensure trading is open
require(tradingOpen,"trading is not yet open");
// Block known bots from selling - If you think this was a mistake please contact the Stealth Team
require(!bots[from], "Stealth is a Bot Free Zone");
// anti bot code - checks for buys and sells in the same block or within the sellCoolDownTime
if (antiBotEnabled) {
uint256 lastBuy = _lastBuy[from];
require(block.timestamp > lastBuy, "Sorry - no FrontRunning allowed right now");
require(cooldown[from] < block.timestamp);
cooldown[from] = block.timestamp + sellCoolDownTime;
}
// Has Seller made a trade before? If not set to current block timestamp
// We check this again on a sell to make sure they didn't transfer to a new wallet
if (!_hasTraded[from]){
_firstBuy[from] = block.timestamp;
_hasTraded[from] = true;
}
if (swapEnabled) {
// handle sell of tokens in contract for Eth
uint256 contractTokenBalance = balanceOf(address(this));
if (contractTokenBalance >= minTokensToSell) {
if (!inSwap) {
swapTokensForEth(contractTokenBalance);
uint256 contractETHBalance = address(this).balance;
if(contractETHBalance > 0) {
sendETHToWallet(address(this).balance);
}
}
}
}
// Check to see if just taking profits or selling over 5%
bool justTakingProfits = _justTakingProfits(amount, from);
uint256 numHours = _getHours(_lastSell[from], block.timestamp);
uint256 numDays = (numHours / 24);
if (justTakingProfits) {
// just taking profits but need to make sure its been more than 7 days since last sell if so
if (numDays < 7) {
_firstBuy[from] = block.timestamp;
_lastBuy[from] = block.timestamp;
}
} else {
if (numDays < 84) {
// sold over 5% so we reset the last buy to be now
_firstBuy[from] = block.timestamp;
_lastBuy[from] = block.timestamp;
}
}
// Record last sell timestamp
_lastSell[from] = block.timestamp;
// Transfer with taxes
_tokenTransferTaxed(from,to,amount);
//} else if (from == uniswapV2Pair && to != address(uniswapV2Router) && to != owner() && to != address(this)) {
} else if ((from == uniswapV2Pair) && ! _isExcludedFromFee[to]) {
// Buying from uniswapV2Pair:
// ensure trading is open
require(tradingOpen,"trading is not yet open");
// Has buyer made a trade before? If not set to current block timestamp
if (!_hasTraded[to]){
_firstBuy[to] = block.timestamp;
_hasTraded[to] = true;
}
// snapshot the last buy timestamp
_lastBuy[to] = block.timestamp;
// Simple Transfer with no taxes
_transferFree(from, to, amount);
} else {
// Other transfer
// Block known bots from selling - If you think this was a mistake please contact the Stealth Team
require(!bots[from] && !bots[to], "Stealth is a Bot Free Zone");
// Handle the case of wallet to wallet transfer
_firstBuy[to] = block.timestamp;
_hasTraded[to] = true;
// Simple Transfer with no taxes
_transferFree(from, to, amount);
}
}
function swapTokensForEth(uint256 tokenAmount) private lockTheSwap {
address[] memory path = new address[](2);
path[0] = address(this);
path[1] = uniswapV2Router.WETH();
_approve(address(this), address(uniswapV2Router), tokenAmount);
uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens(
tokenAmount,
0,
path,
address(this),
block.timestamp
);
}
// If we are doing a tax free Transfer that happens here after _transfer:
function _transferFree(address sender, address recipient, uint256 tAmount) private {
_balances[sender] = _balances[sender].sub(tAmount);
_balances[recipient] = _balances[recipient].add(tAmount);
emit Transfer(sender, recipient, tAmount);
}
// If we are doing a taxed Transfer that happens here after _transfer:
function _tokenTransferTaxed(address sender, address recipient, uint256 amount) private {
_transferTaxed(sender, recipient, amount);
}
function _transferTaxed(address sender, address recipient, uint256 tAmount) private {
// Calculate the taxed token amount
uint256 tTeam = _getTaxedValue(tAmount, sender);
uint256 transferAmount = tAmount - tTeam;
_balances[sender] = _balances[sender].sub(tAmount);
_balances[recipient] = _balances[recipient].add(transferAmount);
_takeTeam(tTeam);
emit Transfer(sender, recipient, transferAmount);
}
function _takeTeam(uint256 tTeam) private {
_balances[address(this)] = _balances[address(this)].add(tTeam);
}
// Check to see if the sell amount is greater than 5% of tokens in a 7 day period
function _justTakingProfits(uint256 sellAmount, address account) private view returns(bool) {
// Basic cheak to see if we are selling more than 5% - if so return false
if ((sellAmount * 20) > _balances[account]) {
return false;
} else {
return true;
}
}
// Calculate the number of taxed tokens for a transaction
function _getTaxedValue(uint256 transTokens, address account) private view returns(uint256){
uint256 taxRate = _getTaxRate(account);
if (taxRate == 0) {
return 0;
} else {
uint256 numerator = (transTokens * (10000 - (100 * taxRate)));
return (((transTokens * 10000) - numerator) / 10000);
}
}
// Calculate the current tax rate.
function _getTaxRate(address account) private view returns(uint256) {
uint256 numHours = _getHours(_tradingStartTimestamp, block.timestamp);
if (numHours <= 24){
// 20% Sell Tax first 24 Hours
return 20;
} else if (numHours <= 48){
// 16% Sell Tax second 24 Hours
return 16;
} else {
// 12% Sell Tax starting rate
numHours = _getHours(_firstBuy[account], block.timestamp);
uint256 numDays = (numHours / 24);
if (numDays >= 84 ){
//12 x 7 = 84 = tax free!
return 0;
} else {
uint256 numWeeks = (numDays / 7);
return (12 - numWeeks);
}
}
}
// Calculate the number of hours that have passed between endDate and startDate:
function _getHours(uint256 startDate, uint256 endDate) private pure returns(uint256){
return ((endDate - startDate) / 60 / 60);
}
receive() external payable {}
function manualswap() external {
require(_msgSender() == _stealthMultiSigWallet || _msgSender() == address(this) || _msgSender() == owner());
uint256 contractBalance = balanceOf(address(this));
swapTokensForEth(contractBalance);
}
function manualsend() external {
require(_msgSender() == _stealthMultiSigWallet || _msgSender() == address(this) || _msgSender() == owner());
uint256 contractETHBalance = address(this).balance;
sendETHToWallet(contractETHBalance);
}
function airdrop(address[] memory _user, uint256[] memory _amount) external onlyOwner {
uint256 len = _user.length;
require(len == _amount.length);
for (uint256 i = 0; i < len; i++) {
_balances[_msgSender()] = _balances[_msgSender()].sub(_amount[i], "ERC20: transfer amount exceeds balance");
_balances[_user[i]] = _balances[_user[i]].add(_amount[i]);
emit Transfer(_msgSender(), _user[i], _amount[i]);
}
}
function setMultipleBots(address[] memory bots_) public onlyOwner {
for (uint i = 0; i < bots_.length; i++) {
bots[bots_[i]] = true;
}
}
function setBot(address isbot) public onlyOwner {
bots[isbot] = true;
}
function deleteBot(address notbot) public onlyOwner {
bots[notbot] = false;
}
function isBlacklisted(address isbot) public view returns(bool) {
return bots[isbot];
}
function setAntiBotMode(bool onoff) external onlyOwner() {
antiBotEnabled = onoff;
}
function isAntiBotEnabled() public view returns(bool) {
return antiBotEnabled;
}
function excludeFromFee(address account) public onlyOwner {
_isExcludedFromFee[account] = true;
}
function includeInFee(address account) public onlyOwner {
_isExcludedFromFee[account] = false;
}
function setSellCoolDownTime(uint256 _newTime) public onlyOwner {
sellCoolDownTime = _newTime;
}
function updateRouter(IUniswapV2Router02 newRouter, address newPair) external onlyOwner {
uniswapV2Router = newRouter;
uniswapV2Pair = newPair;
}
function sendETHToWallet(uint256 amount) private {
_stealthMultiSigWallet.transfer(amount);
}
function startTrading() external onlyOwner() {
require(!tradingOpen,"trading is already open");
antiBotEnabled = true;
swapEnabled = true;
tradingOpen = true;
_tradingStartTimestamp = block.timestamp;
}
function setSwapEnabledMode(bool swap) external onlyOwner {
swapEnabled = swap;
}
function isTradingOpen() public view returns(bool) {
return tradingOpen;
}
} | _justTakingProfits | function _justTakingProfits(uint256 sellAmount, address account) private view returns(bool) {
// Basic cheak to see if we are selling more than 5% - if so return false
if ((sellAmount * 20) > _balances[account]) {
return false;
} else {
return true;
}
}
| // Check to see if the sell amount is greater than 5% of tokens in a 7 day period | LineComment | v0.8.6+commit.11564f7e | None | ipfs://d19ce80d824c23f20ef23ce6fa9664081761593819659a6fbe6272b3a7dedce6 | {
"func_code_index": [
10306,
10631
]
} | 3,590 |
||
Stealth | Stealth.sol | 0x00000000f2cfa550ad4aae0f33bcaad5164900be | Solidity | Stealth | contract Stealth is Context, IERC20, Ownable {
using SafeMath for uint256;
// If you are reading this then welcome - this is where the work happens.
// StealthStandard Check
mapping (address => uint256) private _balances;
mapping (address => uint256) private _firstBuy;
mapping (address => uint256) private _lastBuy;
mapping (address => uint256) private _lastSell;
mapping (address => mapping (address => uint256)) private _allowances;
mapping (address => bool) private _isExcludedFromFee;
mapping (address => bool) private _hasTraded;
mapping (address => bool) private bots;
mapping (address => uint) private cooldown;
uint256 private constant _tTotal = 1000000000000 * 10**18;
uint256 private _tradingStartTimestamp;
uint256 public sellCoolDownTime = 60 seconds;
uint256 private minTokensToSell = _tTotal.div(100000);
address payable private _stealthMultiSigWallet;
string private constant _name = "Stealth Standard";
string private constant _symbol = "$STEALTH";
uint8 private constant _decimals = 18;
IUniswapV2Router02 public uniswapV2Router;
address public uniswapV2Pair;
bool private tradingOpen = false;
bool private inSwap = false;
bool private swapEnabled = false;
bool private antiBotEnabled = false;
modifier lockTheSwap {
inSwap = true;
_;
inSwap = false;
}
constructor () {
_stealthMultiSigWallet = payable(0x852a8cb5D5e09133EDa0713C1A475A5B7dE80226);
IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D);
address _uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory()).createPair(address(this), _uniswapV2Router.WETH());
uniswapV2Router = _uniswapV2Router;
uniswapV2Pair = _uniswapV2Pair;
_balances[_msgSender()] = _tTotal;
_isExcludedFromFee[owner()] = true;
_isExcludedFromFee[address(this)] = true;
_isExcludedFromFee[_stealthMultiSigWallet] = true;
emit Transfer(address(0), _msgSender(), _tTotal);
}
function name() public pure returns (string memory) {
return _name;
}
function symbol() public pure returns (string memory) {
return _symbol;
}
function decimals() public pure returns (uint8) {
return _decimals;
}
function totalSupply() public pure override returns (uint256) {
return _tTotal;
}
function balanceOf(address account) public view override returns (uint256) {
return _balances[account];
}
function transfer(address recipient, uint256 amount) public override returns (bool) {
_transfer(_msgSender(), recipient, amount);
return true;
}
function allowance(address owner, address spender) public view override returns (uint256) {
return _allowances[owner][spender];
}
function approve(address spender, uint256 amount) public override returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) {
_transfer(sender, recipient, amount);
_approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance"));
return true;
}
function _approve(address owner, address spender, uint256 amount) private {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
function _transfer(address from, address to, uint256 amount) private {
require(from != address(0), "ERC20: transfer from the zero address");
require(to != address(0), "ERC20: transfer to the zero address");
require(amount > 0, "Transfer amount must be greater than zero");
require(balanceOf(from) >= amount,"Not enough balance for tx");
// Check if we are buying or selling, or simply transferring
//if (to == uniswapV2Pair && from != address(uniswapV2Router) && from != owner() && from != address(this) && ! _isExcludedFromFee[from]) {
if ((to == uniswapV2Pair) && ! _isExcludedFromFee[from]) {
// Selling to uniswapV2Pair:
// ensure trading is open
require(tradingOpen,"trading is not yet open");
// Block known bots from selling - If you think this was a mistake please contact the Stealth Team
require(!bots[from], "Stealth is a Bot Free Zone");
// anti bot code - checks for buys and sells in the same block or within the sellCoolDownTime
if (antiBotEnabled) {
uint256 lastBuy = _lastBuy[from];
require(block.timestamp > lastBuy, "Sorry - no FrontRunning allowed right now");
require(cooldown[from] < block.timestamp);
cooldown[from] = block.timestamp + sellCoolDownTime;
}
// Has Seller made a trade before? If not set to current block timestamp
// We check this again on a sell to make sure they didn't transfer to a new wallet
if (!_hasTraded[from]){
_firstBuy[from] = block.timestamp;
_hasTraded[from] = true;
}
if (swapEnabled) {
// handle sell of tokens in contract for Eth
uint256 contractTokenBalance = balanceOf(address(this));
if (contractTokenBalance >= minTokensToSell) {
if (!inSwap) {
swapTokensForEth(contractTokenBalance);
uint256 contractETHBalance = address(this).balance;
if(contractETHBalance > 0) {
sendETHToWallet(address(this).balance);
}
}
}
}
// Check to see if just taking profits or selling over 5%
bool justTakingProfits = _justTakingProfits(amount, from);
uint256 numHours = _getHours(_lastSell[from], block.timestamp);
uint256 numDays = (numHours / 24);
if (justTakingProfits) {
// just taking profits but need to make sure its been more than 7 days since last sell if so
if (numDays < 7) {
_firstBuy[from] = block.timestamp;
_lastBuy[from] = block.timestamp;
}
} else {
if (numDays < 84) {
// sold over 5% so we reset the last buy to be now
_firstBuy[from] = block.timestamp;
_lastBuy[from] = block.timestamp;
}
}
// Record last sell timestamp
_lastSell[from] = block.timestamp;
// Transfer with taxes
_tokenTransferTaxed(from,to,amount);
//} else if (from == uniswapV2Pair && to != address(uniswapV2Router) && to != owner() && to != address(this)) {
} else if ((from == uniswapV2Pair) && ! _isExcludedFromFee[to]) {
// Buying from uniswapV2Pair:
// ensure trading is open
require(tradingOpen,"trading is not yet open");
// Has buyer made a trade before? If not set to current block timestamp
if (!_hasTraded[to]){
_firstBuy[to] = block.timestamp;
_hasTraded[to] = true;
}
// snapshot the last buy timestamp
_lastBuy[to] = block.timestamp;
// Simple Transfer with no taxes
_transferFree(from, to, amount);
} else {
// Other transfer
// Block known bots from selling - If you think this was a mistake please contact the Stealth Team
require(!bots[from] && !bots[to], "Stealth is a Bot Free Zone");
// Handle the case of wallet to wallet transfer
_firstBuy[to] = block.timestamp;
_hasTraded[to] = true;
// Simple Transfer with no taxes
_transferFree(from, to, amount);
}
}
function swapTokensForEth(uint256 tokenAmount) private lockTheSwap {
address[] memory path = new address[](2);
path[0] = address(this);
path[1] = uniswapV2Router.WETH();
_approve(address(this), address(uniswapV2Router), tokenAmount);
uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens(
tokenAmount,
0,
path,
address(this),
block.timestamp
);
}
// If we are doing a tax free Transfer that happens here after _transfer:
function _transferFree(address sender, address recipient, uint256 tAmount) private {
_balances[sender] = _balances[sender].sub(tAmount);
_balances[recipient] = _balances[recipient].add(tAmount);
emit Transfer(sender, recipient, tAmount);
}
// If we are doing a taxed Transfer that happens here after _transfer:
function _tokenTransferTaxed(address sender, address recipient, uint256 amount) private {
_transferTaxed(sender, recipient, amount);
}
function _transferTaxed(address sender, address recipient, uint256 tAmount) private {
// Calculate the taxed token amount
uint256 tTeam = _getTaxedValue(tAmount, sender);
uint256 transferAmount = tAmount - tTeam;
_balances[sender] = _balances[sender].sub(tAmount);
_balances[recipient] = _balances[recipient].add(transferAmount);
_takeTeam(tTeam);
emit Transfer(sender, recipient, transferAmount);
}
function _takeTeam(uint256 tTeam) private {
_balances[address(this)] = _balances[address(this)].add(tTeam);
}
// Check to see if the sell amount is greater than 5% of tokens in a 7 day period
function _justTakingProfits(uint256 sellAmount, address account) private view returns(bool) {
// Basic cheak to see if we are selling more than 5% - if so return false
if ((sellAmount * 20) > _balances[account]) {
return false;
} else {
return true;
}
}
// Calculate the number of taxed tokens for a transaction
function _getTaxedValue(uint256 transTokens, address account) private view returns(uint256){
uint256 taxRate = _getTaxRate(account);
if (taxRate == 0) {
return 0;
} else {
uint256 numerator = (transTokens * (10000 - (100 * taxRate)));
return (((transTokens * 10000) - numerator) / 10000);
}
}
// Calculate the current tax rate.
function _getTaxRate(address account) private view returns(uint256) {
uint256 numHours = _getHours(_tradingStartTimestamp, block.timestamp);
if (numHours <= 24){
// 20% Sell Tax first 24 Hours
return 20;
} else if (numHours <= 48){
// 16% Sell Tax second 24 Hours
return 16;
} else {
// 12% Sell Tax starting rate
numHours = _getHours(_firstBuy[account], block.timestamp);
uint256 numDays = (numHours / 24);
if (numDays >= 84 ){
//12 x 7 = 84 = tax free!
return 0;
} else {
uint256 numWeeks = (numDays / 7);
return (12 - numWeeks);
}
}
}
// Calculate the number of hours that have passed between endDate and startDate:
function _getHours(uint256 startDate, uint256 endDate) private pure returns(uint256){
return ((endDate - startDate) / 60 / 60);
}
receive() external payable {}
function manualswap() external {
require(_msgSender() == _stealthMultiSigWallet || _msgSender() == address(this) || _msgSender() == owner());
uint256 contractBalance = balanceOf(address(this));
swapTokensForEth(contractBalance);
}
function manualsend() external {
require(_msgSender() == _stealthMultiSigWallet || _msgSender() == address(this) || _msgSender() == owner());
uint256 contractETHBalance = address(this).balance;
sendETHToWallet(contractETHBalance);
}
function airdrop(address[] memory _user, uint256[] memory _amount) external onlyOwner {
uint256 len = _user.length;
require(len == _amount.length);
for (uint256 i = 0; i < len; i++) {
_balances[_msgSender()] = _balances[_msgSender()].sub(_amount[i], "ERC20: transfer amount exceeds balance");
_balances[_user[i]] = _balances[_user[i]].add(_amount[i]);
emit Transfer(_msgSender(), _user[i], _amount[i]);
}
}
function setMultipleBots(address[] memory bots_) public onlyOwner {
for (uint i = 0; i < bots_.length; i++) {
bots[bots_[i]] = true;
}
}
function setBot(address isbot) public onlyOwner {
bots[isbot] = true;
}
function deleteBot(address notbot) public onlyOwner {
bots[notbot] = false;
}
function isBlacklisted(address isbot) public view returns(bool) {
return bots[isbot];
}
function setAntiBotMode(bool onoff) external onlyOwner() {
antiBotEnabled = onoff;
}
function isAntiBotEnabled() public view returns(bool) {
return antiBotEnabled;
}
function excludeFromFee(address account) public onlyOwner {
_isExcludedFromFee[account] = true;
}
function includeInFee(address account) public onlyOwner {
_isExcludedFromFee[account] = false;
}
function setSellCoolDownTime(uint256 _newTime) public onlyOwner {
sellCoolDownTime = _newTime;
}
function updateRouter(IUniswapV2Router02 newRouter, address newPair) external onlyOwner {
uniswapV2Router = newRouter;
uniswapV2Pair = newPair;
}
function sendETHToWallet(uint256 amount) private {
_stealthMultiSigWallet.transfer(amount);
}
function startTrading() external onlyOwner() {
require(!tradingOpen,"trading is already open");
antiBotEnabled = true;
swapEnabled = true;
tradingOpen = true;
_tradingStartTimestamp = block.timestamp;
}
function setSwapEnabledMode(bool swap) external onlyOwner {
swapEnabled = swap;
}
function isTradingOpen() public view returns(bool) {
return tradingOpen;
}
} | _getTaxedValue | function _getTaxedValue(uint256 transTokens, address account) private view returns(uint256){
uint256 taxRate = _getTaxRate(account);
if (taxRate == 0) {
return 0;
} else {
uint256 numerator = (transTokens * (10000 - (100 * taxRate)));
return (((transTokens * 10000) - numerator) / 10000);
}
}
| // Calculate the number of taxed tokens for a transaction | LineComment | v0.8.6+commit.11564f7e | None | ipfs://d19ce80d824c23f20ef23ce6fa9664081761593819659a6fbe6272b3a7dedce6 | {
"func_code_index": [
10697,
11074
]
} | 3,591 |
||
Stealth | Stealth.sol | 0x00000000f2cfa550ad4aae0f33bcaad5164900be | Solidity | Stealth | contract Stealth is Context, IERC20, Ownable {
using SafeMath for uint256;
// If you are reading this then welcome - this is where the work happens.
// StealthStandard Check
mapping (address => uint256) private _balances;
mapping (address => uint256) private _firstBuy;
mapping (address => uint256) private _lastBuy;
mapping (address => uint256) private _lastSell;
mapping (address => mapping (address => uint256)) private _allowances;
mapping (address => bool) private _isExcludedFromFee;
mapping (address => bool) private _hasTraded;
mapping (address => bool) private bots;
mapping (address => uint) private cooldown;
uint256 private constant _tTotal = 1000000000000 * 10**18;
uint256 private _tradingStartTimestamp;
uint256 public sellCoolDownTime = 60 seconds;
uint256 private minTokensToSell = _tTotal.div(100000);
address payable private _stealthMultiSigWallet;
string private constant _name = "Stealth Standard";
string private constant _symbol = "$STEALTH";
uint8 private constant _decimals = 18;
IUniswapV2Router02 public uniswapV2Router;
address public uniswapV2Pair;
bool private tradingOpen = false;
bool private inSwap = false;
bool private swapEnabled = false;
bool private antiBotEnabled = false;
modifier lockTheSwap {
inSwap = true;
_;
inSwap = false;
}
constructor () {
_stealthMultiSigWallet = payable(0x852a8cb5D5e09133EDa0713C1A475A5B7dE80226);
IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D);
address _uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory()).createPair(address(this), _uniswapV2Router.WETH());
uniswapV2Router = _uniswapV2Router;
uniswapV2Pair = _uniswapV2Pair;
_balances[_msgSender()] = _tTotal;
_isExcludedFromFee[owner()] = true;
_isExcludedFromFee[address(this)] = true;
_isExcludedFromFee[_stealthMultiSigWallet] = true;
emit Transfer(address(0), _msgSender(), _tTotal);
}
function name() public pure returns (string memory) {
return _name;
}
function symbol() public pure returns (string memory) {
return _symbol;
}
function decimals() public pure returns (uint8) {
return _decimals;
}
function totalSupply() public pure override returns (uint256) {
return _tTotal;
}
function balanceOf(address account) public view override returns (uint256) {
return _balances[account];
}
function transfer(address recipient, uint256 amount) public override returns (bool) {
_transfer(_msgSender(), recipient, amount);
return true;
}
function allowance(address owner, address spender) public view override returns (uint256) {
return _allowances[owner][spender];
}
function approve(address spender, uint256 amount) public override returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) {
_transfer(sender, recipient, amount);
_approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance"));
return true;
}
function _approve(address owner, address spender, uint256 amount) private {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
function _transfer(address from, address to, uint256 amount) private {
require(from != address(0), "ERC20: transfer from the zero address");
require(to != address(0), "ERC20: transfer to the zero address");
require(amount > 0, "Transfer amount must be greater than zero");
require(balanceOf(from) >= amount,"Not enough balance for tx");
// Check if we are buying or selling, or simply transferring
//if (to == uniswapV2Pair && from != address(uniswapV2Router) && from != owner() && from != address(this) && ! _isExcludedFromFee[from]) {
if ((to == uniswapV2Pair) && ! _isExcludedFromFee[from]) {
// Selling to uniswapV2Pair:
// ensure trading is open
require(tradingOpen,"trading is not yet open");
// Block known bots from selling - If you think this was a mistake please contact the Stealth Team
require(!bots[from], "Stealth is a Bot Free Zone");
// anti bot code - checks for buys and sells in the same block or within the sellCoolDownTime
if (antiBotEnabled) {
uint256 lastBuy = _lastBuy[from];
require(block.timestamp > lastBuy, "Sorry - no FrontRunning allowed right now");
require(cooldown[from] < block.timestamp);
cooldown[from] = block.timestamp + sellCoolDownTime;
}
// Has Seller made a trade before? If not set to current block timestamp
// We check this again on a sell to make sure they didn't transfer to a new wallet
if (!_hasTraded[from]){
_firstBuy[from] = block.timestamp;
_hasTraded[from] = true;
}
if (swapEnabled) {
// handle sell of tokens in contract for Eth
uint256 contractTokenBalance = balanceOf(address(this));
if (contractTokenBalance >= minTokensToSell) {
if (!inSwap) {
swapTokensForEth(contractTokenBalance);
uint256 contractETHBalance = address(this).balance;
if(contractETHBalance > 0) {
sendETHToWallet(address(this).balance);
}
}
}
}
// Check to see if just taking profits or selling over 5%
bool justTakingProfits = _justTakingProfits(amount, from);
uint256 numHours = _getHours(_lastSell[from], block.timestamp);
uint256 numDays = (numHours / 24);
if (justTakingProfits) {
// just taking profits but need to make sure its been more than 7 days since last sell if so
if (numDays < 7) {
_firstBuy[from] = block.timestamp;
_lastBuy[from] = block.timestamp;
}
} else {
if (numDays < 84) {
// sold over 5% so we reset the last buy to be now
_firstBuy[from] = block.timestamp;
_lastBuy[from] = block.timestamp;
}
}
// Record last sell timestamp
_lastSell[from] = block.timestamp;
// Transfer with taxes
_tokenTransferTaxed(from,to,amount);
//} else if (from == uniswapV2Pair && to != address(uniswapV2Router) && to != owner() && to != address(this)) {
} else if ((from == uniswapV2Pair) && ! _isExcludedFromFee[to]) {
// Buying from uniswapV2Pair:
// ensure trading is open
require(tradingOpen,"trading is not yet open");
// Has buyer made a trade before? If not set to current block timestamp
if (!_hasTraded[to]){
_firstBuy[to] = block.timestamp;
_hasTraded[to] = true;
}
// snapshot the last buy timestamp
_lastBuy[to] = block.timestamp;
// Simple Transfer with no taxes
_transferFree(from, to, amount);
} else {
// Other transfer
// Block known bots from selling - If you think this was a mistake please contact the Stealth Team
require(!bots[from] && !bots[to], "Stealth is a Bot Free Zone");
// Handle the case of wallet to wallet transfer
_firstBuy[to] = block.timestamp;
_hasTraded[to] = true;
// Simple Transfer with no taxes
_transferFree(from, to, amount);
}
}
function swapTokensForEth(uint256 tokenAmount) private lockTheSwap {
address[] memory path = new address[](2);
path[0] = address(this);
path[1] = uniswapV2Router.WETH();
_approve(address(this), address(uniswapV2Router), tokenAmount);
uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens(
tokenAmount,
0,
path,
address(this),
block.timestamp
);
}
// If we are doing a tax free Transfer that happens here after _transfer:
function _transferFree(address sender, address recipient, uint256 tAmount) private {
_balances[sender] = _balances[sender].sub(tAmount);
_balances[recipient] = _balances[recipient].add(tAmount);
emit Transfer(sender, recipient, tAmount);
}
// If we are doing a taxed Transfer that happens here after _transfer:
function _tokenTransferTaxed(address sender, address recipient, uint256 amount) private {
_transferTaxed(sender, recipient, amount);
}
function _transferTaxed(address sender, address recipient, uint256 tAmount) private {
// Calculate the taxed token amount
uint256 tTeam = _getTaxedValue(tAmount, sender);
uint256 transferAmount = tAmount - tTeam;
_balances[sender] = _balances[sender].sub(tAmount);
_balances[recipient] = _balances[recipient].add(transferAmount);
_takeTeam(tTeam);
emit Transfer(sender, recipient, transferAmount);
}
function _takeTeam(uint256 tTeam) private {
_balances[address(this)] = _balances[address(this)].add(tTeam);
}
// Check to see if the sell amount is greater than 5% of tokens in a 7 day period
function _justTakingProfits(uint256 sellAmount, address account) private view returns(bool) {
// Basic cheak to see if we are selling more than 5% - if so return false
if ((sellAmount * 20) > _balances[account]) {
return false;
} else {
return true;
}
}
// Calculate the number of taxed tokens for a transaction
function _getTaxedValue(uint256 transTokens, address account) private view returns(uint256){
uint256 taxRate = _getTaxRate(account);
if (taxRate == 0) {
return 0;
} else {
uint256 numerator = (transTokens * (10000 - (100 * taxRate)));
return (((transTokens * 10000) - numerator) / 10000);
}
}
// Calculate the current tax rate.
function _getTaxRate(address account) private view returns(uint256) {
uint256 numHours = _getHours(_tradingStartTimestamp, block.timestamp);
if (numHours <= 24){
// 20% Sell Tax first 24 Hours
return 20;
} else if (numHours <= 48){
// 16% Sell Tax second 24 Hours
return 16;
} else {
// 12% Sell Tax starting rate
numHours = _getHours(_firstBuy[account], block.timestamp);
uint256 numDays = (numHours / 24);
if (numDays >= 84 ){
//12 x 7 = 84 = tax free!
return 0;
} else {
uint256 numWeeks = (numDays / 7);
return (12 - numWeeks);
}
}
}
// Calculate the number of hours that have passed between endDate and startDate:
function _getHours(uint256 startDate, uint256 endDate) private pure returns(uint256){
return ((endDate - startDate) / 60 / 60);
}
receive() external payable {}
function manualswap() external {
require(_msgSender() == _stealthMultiSigWallet || _msgSender() == address(this) || _msgSender() == owner());
uint256 contractBalance = balanceOf(address(this));
swapTokensForEth(contractBalance);
}
function manualsend() external {
require(_msgSender() == _stealthMultiSigWallet || _msgSender() == address(this) || _msgSender() == owner());
uint256 contractETHBalance = address(this).balance;
sendETHToWallet(contractETHBalance);
}
function airdrop(address[] memory _user, uint256[] memory _amount) external onlyOwner {
uint256 len = _user.length;
require(len == _amount.length);
for (uint256 i = 0; i < len; i++) {
_balances[_msgSender()] = _balances[_msgSender()].sub(_amount[i], "ERC20: transfer amount exceeds balance");
_balances[_user[i]] = _balances[_user[i]].add(_amount[i]);
emit Transfer(_msgSender(), _user[i], _amount[i]);
}
}
function setMultipleBots(address[] memory bots_) public onlyOwner {
for (uint i = 0; i < bots_.length; i++) {
bots[bots_[i]] = true;
}
}
function setBot(address isbot) public onlyOwner {
bots[isbot] = true;
}
function deleteBot(address notbot) public onlyOwner {
bots[notbot] = false;
}
function isBlacklisted(address isbot) public view returns(bool) {
return bots[isbot];
}
function setAntiBotMode(bool onoff) external onlyOwner() {
antiBotEnabled = onoff;
}
function isAntiBotEnabled() public view returns(bool) {
return antiBotEnabled;
}
function excludeFromFee(address account) public onlyOwner {
_isExcludedFromFee[account] = true;
}
function includeInFee(address account) public onlyOwner {
_isExcludedFromFee[account] = false;
}
function setSellCoolDownTime(uint256 _newTime) public onlyOwner {
sellCoolDownTime = _newTime;
}
function updateRouter(IUniswapV2Router02 newRouter, address newPair) external onlyOwner {
uniswapV2Router = newRouter;
uniswapV2Pair = newPair;
}
function sendETHToWallet(uint256 amount) private {
_stealthMultiSigWallet.transfer(amount);
}
function startTrading() external onlyOwner() {
require(!tradingOpen,"trading is already open");
antiBotEnabled = true;
swapEnabled = true;
tradingOpen = true;
_tradingStartTimestamp = block.timestamp;
}
function setSwapEnabledMode(bool swap) external onlyOwner {
swapEnabled = swap;
}
function isTradingOpen() public view returns(bool) {
return tradingOpen;
}
} | _getTaxRate | function _getTaxRate(address account) private view returns(uint256) {
uint256 numHours = _getHours(_tradingStartTimestamp, block.timestamp);
if (numHours <= 24){
// 20% Sell Tax first 24 Hours
return 20;
} else if (numHours <= 48){
// 16% Sell Tax second 24 Hours
return 16;
} else {
// 12% Sell Tax starting rate
numHours = _getHours(_firstBuy[account], block.timestamp);
uint256 numDays = (numHours / 24);
if (numDays >= 84 ){
//12 x 7 = 84 = tax free!
return 0;
} else {
uint256 numWeeks = (numDays / 7);
return (12 - numWeeks);
}
}
}
| // Calculate the current tax rate. | LineComment | v0.8.6+commit.11564f7e | None | ipfs://d19ce80d824c23f20ef23ce6fa9664081761593819659a6fbe6272b3a7dedce6 | {
"func_code_index": [
11117,
11906
]
} | 3,592 |
||
Stealth | Stealth.sol | 0x00000000f2cfa550ad4aae0f33bcaad5164900be | Solidity | Stealth | contract Stealth is Context, IERC20, Ownable {
using SafeMath for uint256;
// If you are reading this then welcome - this is where the work happens.
// StealthStandard Check
mapping (address => uint256) private _balances;
mapping (address => uint256) private _firstBuy;
mapping (address => uint256) private _lastBuy;
mapping (address => uint256) private _lastSell;
mapping (address => mapping (address => uint256)) private _allowances;
mapping (address => bool) private _isExcludedFromFee;
mapping (address => bool) private _hasTraded;
mapping (address => bool) private bots;
mapping (address => uint) private cooldown;
uint256 private constant _tTotal = 1000000000000 * 10**18;
uint256 private _tradingStartTimestamp;
uint256 public sellCoolDownTime = 60 seconds;
uint256 private minTokensToSell = _tTotal.div(100000);
address payable private _stealthMultiSigWallet;
string private constant _name = "Stealth Standard";
string private constant _symbol = "$STEALTH";
uint8 private constant _decimals = 18;
IUniswapV2Router02 public uniswapV2Router;
address public uniswapV2Pair;
bool private tradingOpen = false;
bool private inSwap = false;
bool private swapEnabled = false;
bool private antiBotEnabled = false;
modifier lockTheSwap {
inSwap = true;
_;
inSwap = false;
}
constructor () {
_stealthMultiSigWallet = payable(0x852a8cb5D5e09133EDa0713C1A475A5B7dE80226);
IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D);
address _uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory()).createPair(address(this), _uniswapV2Router.WETH());
uniswapV2Router = _uniswapV2Router;
uniswapV2Pair = _uniswapV2Pair;
_balances[_msgSender()] = _tTotal;
_isExcludedFromFee[owner()] = true;
_isExcludedFromFee[address(this)] = true;
_isExcludedFromFee[_stealthMultiSigWallet] = true;
emit Transfer(address(0), _msgSender(), _tTotal);
}
function name() public pure returns (string memory) {
return _name;
}
function symbol() public pure returns (string memory) {
return _symbol;
}
function decimals() public pure returns (uint8) {
return _decimals;
}
function totalSupply() public pure override returns (uint256) {
return _tTotal;
}
function balanceOf(address account) public view override returns (uint256) {
return _balances[account];
}
function transfer(address recipient, uint256 amount) public override returns (bool) {
_transfer(_msgSender(), recipient, amount);
return true;
}
function allowance(address owner, address spender) public view override returns (uint256) {
return _allowances[owner][spender];
}
function approve(address spender, uint256 amount) public override returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) {
_transfer(sender, recipient, amount);
_approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance"));
return true;
}
function _approve(address owner, address spender, uint256 amount) private {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
function _transfer(address from, address to, uint256 amount) private {
require(from != address(0), "ERC20: transfer from the zero address");
require(to != address(0), "ERC20: transfer to the zero address");
require(amount > 0, "Transfer amount must be greater than zero");
require(balanceOf(from) >= amount,"Not enough balance for tx");
// Check if we are buying or selling, or simply transferring
//if (to == uniswapV2Pair && from != address(uniswapV2Router) && from != owner() && from != address(this) && ! _isExcludedFromFee[from]) {
if ((to == uniswapV2Pair) && ! _isExcludedFromFee[from]) {
// Selling to uniswapV2Pair:
// ensure trading is open
require(tradingOpen,"trading is not yet open");
// Block known bots from selling - If you think this was a mistake please contact the Stealth Team
require(!bots[from], "Stealth is a Bot Free Zone");
// anti bot code - checks for buys and sells in the same block or within the sellCoolDownTime
if (antiBotEnabled) {
uint256 lastBuy = _lastBuy[from];
require(block.timestamp > lastBuy, "Sorry - no FrontRunning allowed right now");
require(cooldown[from] < block.timestamp);
cooldown[from] = block.timestamp + sellCoolDownTime;
}
// Has Seller made a trade before? If not set to current block timestamp
// We check this again on a sell to make sure they didn't transfer to a new wallet
if (!_hasTraded[from]){
_firstBuy[from] = block.timestamp;
_hasTraded[from] = true;
}
if (swapEnabled) {
// handle sell of tokens in contract for Eth
uint256 contractTokenBalance = balanceOf(address(this));
if (contractTokenBalance >= minTokensToSell) {
if (!inSwap) {
swapTokensForEth(contractTokenBalance);
uint256 contractETHBalance = address(this).balance;
if(contractETHBalance > 0) {
sendETHToWallet(address(this).balance);
}
}
}
}
// Check to see if just taking profits or selling over 5%
bool justTakingProfits = _justTakingProfits(amount, from);
uint256 numHours = _getHours(_lastSell[from], block.timestamp);
uint256 numDays = (numHours / 24);
if (justTakingProfits) {
// just taking profits but need to make sure its been more than 7 days since last sell if so
if (numDays < 7) {
_firstBuy[from] = block.timestamp;
_lastBuy[from] = block.timestamp;
}
} else {
if (numDays < 84) {
// sold over 5% so we reset the last buy to be now
_firstBuy[from] = block.timestamp;
_lastBuy[from] = block.timestamp;
}
}
// Record last sell timestamp
_lastSell[from] = block.timestamp;
// Transfer with taxes
_tokenTransferTaxed(from,to,amount);
//} else if (from == uniswapV2Pair && to != address(uniswapV2Router) && to != owner() && to != address(this)) {
} else if ((from == uniswapV2Pair) && ! _isExcludedFromFee[to]) {
// Buying from uniswapV2Pair:
// ensure trading is open
require(tradingOpen,"trading is not yet open");
// Has buyer made a trade before? If not set to current block timestamp
if (!_hasTraded[to]){
_firstBuy[to] = block.timestamp;
_hasTraded[to] = true;
}
// snapshot the last buy timestamp
_lastBuy[to] = block.timestamp;
// Simple Transfer with no taxes
_transferFree(from, to, amount);
} else {
// Other transfer
// Block known bots from selling - If you think this was a mistake please contact the Stealth Team
require(!bots[from] && !bots[to], "Stealth is a Bot Free Zone");
// Handle the case of wallet to wallet transfer
_firstBuy[to] = block.timestamp;
_hasTraded[to] = true;
// Simple Transfer with no taxes
_transferFree(from, to, amount);
}
}
function swapTokensForEth(uint256 tokenAmount) private lockTheSwap {
address[] memory path = new address[](2);
path[0] = address(this);
path[1] = uniswapV2Router.WETH();
_approve(address(this), address(uniswapV2Router), tokenAmount);
uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens(
tokenAmount,
0,
path,
address(this),
block.timestamp
);
}
// If we are doing a tax free Transfer that happens here after _transfer:
function _transferFree(address sender, address recipient, uint256 tAmount) private {
_balances[sender] = _balances[sender].sub(tAmount);
_balances[recipient] = _balances[recipient].add(tAmount);
emit Transfer(sender, recipient, tAmount);
}
// If we are doing a taxed Transfer that happens here after _transfer:
function _tokenTransferTaxed(address sender, address recipient, uint256 amount) private {
_transferTaxed(sender, recipient, amount);
}
function _transferTaxed(address sender, address recipient, uint256 tAmount) private {
// Calculate the taxed token amount
uint256 tTeam = _getTaxedValue(tAmount, sender);
uint256 transferAmount = tAmount - tTeam;
_balances[sender] = _balances[sender].sub(tAmount);
_balances[recipient] = _balances[recipient].add(transferAmount);
_takeTeam(tTeam);
emit Transfer(sender, recipient, transferAmount);
}
function _takeTeam(uint256 tTeam) private {
_balances[address(this)] = _balances[address(this)].add(tTeam);
}
// Check to see if the sell amount is greater than 5% of tokens in a 7 day period
function _justTakingProfits(uint256 sellAmount, address account) private view returns(bool) {
// Basic cheak to see if we are selling more than 5% - if so return false
if ((sellAmount * 20) > _balances[account]) {
return false;
} else {
return true;
}
}
// Calculate the number of taxed tokens for a transaction
function _getTaxedValue(uint256 transTokens, address account) private view returns(uint256){
uint256 taxRate = _getTaxRate(account);
if (taxRate == 0) {
return 0;
} else {
uint256 numerator = (transTokens * (10000 - (100 * taxRate)));
return (((transTokens * 10000) - numerator) / 10000);
}
}
// Calculate the current tax rate.
function _getTaxRate(address account) private view returns(uint256) {
uint256 numHours = _getHours(_tradingStartTimestamp, block.timestamp);
if (numHours <= 24){
// 20% Sell Tax first 24 Hours
return 20;
} else if (numHours <= 48){
// 16% Sell Tax second 24 Hours
return 16;
} else {
// 12% Sell Tax starting rate
numHours = _getHours(_firstBuy[account], block.timestamp);
uint256 numDays = (numHours / 24);
if (numDays >= 84 ){
//12 x 7 = 84 = tax free!
return 0;
} else {
uint256 numWeeks = (numDays / 7);
return (12 - numWeeks);
}
}
}
// Calculate the number of hours that have passed between endDate and startDate:
function _getHours(uint256 startDate, uint256 endDate) private pure returns(uint256){
return ((endDate - startDate) / 60 / 60);
}
receive() external payable {}
function manualswap() external {
require(_msgSender() == _stealthMultiSigWallet || _msgSender() == address(this) || _msgSender() == owner());
uint256 contractBalance = balanceOf(address(this));
swapTokensForEth(contractBalance);
}
function manualsend() external {
require(_msgSender() == _stealthMultiSigWallet || _msgSender() == address(this) || _msgSender() == owner());
uint256 contractETHBalance = address(this).balance;
sendETHToWallet(contractETHBalance);
}
function airdrop(address[] memory _user, uint256[] memory _amount) external onlyOwner {
uint256 len = _user.length;
require(len == _amount.length);
for (uint256 i = 0; i < len; i++) {
_balances[_msgSender()] = _balances[_msgSender()].sub(_amount[i], "ERC20: transfer amount exceeds balance");
_balances[_user[i]] = _balances[_user[i]].add(_amount[i]);
emit Transfer(_msgSender(), _user[i], _amount[i]);
}
}
function setMultipleBots(address[] memory bots_) public onlyOwner {
for (uint i = 0; i < bots_.length; i++) {
bots[bots_[i]] = true;
}
}
function setBot(address isbot) public onlyOwner {
bots[isbot] = true;
}
function deleteBot(address notbot) public onlyOwner {
bots[notbot] = false;
}
function isBlacklisted(address isbot) public view returns(bool) {
return bots[isbot];
}
function setAntiBotMode(bool onoff) external onlyOwner() {
antiBotEnabled = onoff;
}
function isAntiBotEnabled() public view returns(bool) {
return antiBotEnabled;
}
function excludeFromFee(address account) public onlyOwner {
_isExcludedFromFee[account] = true;
}
function includeInFee(address account) public onlyOwner {
_isExcludedFromFee[account] = false;
}
function setSellCoolDownTime(uint256 _newTime) public onlyOwner {
sellCoolDownTime = _newTime;
}
function updateRouter(IUniswapV2Router02 newRouter, address newPair) external onlyOwner {
uniswapV2Router = newRouter;
uniswapV2Pair = newPair;
}
function sendETHToWallet(uint256 amount) private {
_stealthMultiSigWallet.transfer(amount);
}
function startTrading() external onlyOwner() {
require(!tradingOpen,"trading is already open");
antiBotEnabled = true;
swapEnabled = true;
tradingOpen = true;
_tradingStartTimestamp = block.timestamp;
}
function setSwapEnabledMode(bool swap) external onlyOwner {
swapEnabled = swap;
}
function isTradingOpen() public view returns(bool) {
return tradingOpen;
}
} | _getHours | function _getHours(uint256 startDate, uint256 endDate) private pure returns(uint256){
return ((endDate - startDate) / 60 / 60);
}
| // Calculate the number of hours that have passed between endDate and startDate: | LineComment | v0.8.6+commit.11564f7e | None | ipfs://d19ce80d824c23f20ef23ce6fa9664081761593819659a6fbe6272b3a7dedce6 | {
"func_code_index": [
11995,
12143
]
} | 3,593 |
||
Registry | contracts/bprotocol/proxy/GnosisSafeProxy.sol | 0xbf698df5591caf546a7e087f5806e216afed666a | Solidity | GnosisSafeProxy | contract GnosisSafeProxy {
// masterCopy always needs to be first declared variable, to ensure that it is at the same location in the contracts to which calls are delegated.
// To reduce deployment costs this variable is internal and needs to be retrieved via `getStorageAt`
address internal masterCopy;
/// @dev Constructor function sets address of master copy contract.
/// @param _masterCopy Master copy address.
constructor(address _masterCopy)
public
{
require(_masterCopy != address(0), "Invalid master copy address provided");
masterCopy = _masterCopy;
}
/// @dev Fallback function forwards all transactions and returns all received return data.
function ()
external
payable
{
// solium-disable-next-line security/no-inline-assembly
assembly {
let masterCopy := and(sload(0), 0xffffffffffffffffffffffffffffffffffffffff)
// 0xa619486e == keccak("masterCopy()"). The value is right padded to 32-bytes with 0s
if eq(calldataload(0), 0xa619486e00000000000000000000000000000000000000000000000000000000) {
mstore(0, masterCopy)
return(0, 0x20)
}
calldatacopy(0, 0, calldatasize())
let success := delegatecall(gas, masterCopy, 0, calldatasize(), 0, 0)
returndatacopy(0, 0, returndatasize())
if eq(success, 0) { revert(0, returndatasize()) }
return(0, returndatasize())
}
}
} | /// @title GnosisSafeProxy - Generic proxy contract allows to execute all transactions applying the code of a master contract.
/// @author Stefan George - <[email protected]>
/// @author Richard Meissner - <[email protected]> | NatSpecSingleLine | function ()
external
payable
{
// solium-disable-next-line security/no-inline-assembly
assembly {
let masterCopy := and(sload(0), 0xffffffffffffffffffffffffffffffffffffffff)
// 0xa619486e == keccak("masterCopy()"). The value is right padded to 32-bytes with 0s
if eq(calldataload(0), 0xa619486e00000000000000000000000000000000000000000000000000000000) {
mstore(0, masterCopy)
return(0, 0x20)
}
calldatacopy(0, 0, calldatasize())
let success := delegatecall(gas, masterCopy, 0, calldatasize(), 0, 0)
returndatacopy(0, 0, returndatasize())
if eq(success, 0) { revert(0, returndatasize()) }
return(0, returndatasize())
}
}
| /// @dev Fallback function forwards all transactions and returns all received return data. | NatSpecSingleLine | v0.5.16+commit.9c3226ce | BSD-3-Clause | bzzr://d74ce75cda79cbf7cd7b9d07daee237c0b3a6d7a453cc770c29801429e3b35e9 | {
"func_code_index": [
732,
1562
]
} | 3,594 |
|
AaveImport | contracts/compound/import/CompoundImportTaker.sol | 0x751961666d8605af1c5ee549205f822f47b04168 | Solidity | CompoundImportTaker | contract CompoundImportTaker is CompoundSaverHelper, ProxyPermission, GasBurner {
ILendingPool public constant lendingPool = ILendingPool(0x398eC7346DcD622eDc5ae82352F02bE94C62d119);
address payable public constant COMPOUND_IMPORT_FLASH_LOAN = 0xaf9f8781A4c39Ce2122019fC05F22e3a662B0A32;
address public constant PROXY_REGISTRY_ADDRESS = 0x4678f0a6958e4D2Bc4F1BAF7Bc52E8F3564f3fE4;
DefisaverLogger public constant logger = DefisaverLogger(0x5c55B921f590a89C1Ebe84dF170E655a82b62126);
/// @notice Starts the process to move users position 1 collateral and 1 borrow
/// @dev User must approve COMPOUND_IMPORT_FLASH_LOAN to pull _cCollateralToken
/// @param _cCollateralToken Collateral we are moving to DSProxy
/// @param _cBorrowToken Borrow token we are moving to DSProxy
function importLoan(address _cCollateralToken, address _cBorrowToken) external burnGas(20) {
address proxy = getProxy();
uint loanAmount = CTokenInterface(_cBorrowToken).borrowBalanceCurrent(msg.sender);
bytes memory paramsData = abi.encode(_cCollateralToken, _cBorrowToken, msg.sender, proxy);
givePermission(COMPOUND_IMPORT_FLASH_LOAN);
lendingPool.flashLoan(COMPOUND_IMPORT_FLASH_LOAN, getUnderlyingAddr(_cBorrowToken), loanAmount, paramsData);
removePermission(COMPOUND_IMPORT_FLASH_LOAN);
logger.Log(address(this), msg.sender, "CompoundImport", abi.encode(loanAmount, 0, _cCollateralToken));
}
/// @notice Gets proxy address, if user doesn't has DSProxy build it
/// @return proxy DsProxy address
function getProxy() internal returns (address proxy) {
proxy = ProxyRegistryInterface(PROXY_REGISTRY_ADDRESS).proxies(msg.sender);
if (proxy == address(0)) {
proxy = ProxyRegistryInterface(PROXY_REGISTRY_ADDRESS).build(msg.sender);
}
}
} | /// @title Imports Compound position from the account to DSProxy | NatSpecSingleLine | importLoan | function importLoan(address _cCollateralToken, address _cBorrowToken) external burnGas(20) {
address proxy = getProxy();
uint loanAmount = CTokenInterface(_cBorrowToken).borrowBalanceCurrent(msg.sender);
bytes memory paramsData = abi.encode(_cCollateralToken, _cBorrowToken, msg.sender, proxy);
givePermission(COMPOUND_IMPORT_FLASH_LOAN);
lendingPool.flashLoan(COMPOUND_IMPORT_FLASH_LOAN, getUnderlyingAddr(_cBorrowToken), loanAmount, paramsData);
removePermission(COMPOUND_IMPORT_FLASH_LOAN);
logger.Log(address(this), msg.sender, "CompoundImport", abi.encode(loanAmount, 0, _cCollateralToken));
}
| /// @notice Starts the process to move users position 1 collateral and 1 borrow
/// @dev User must approve COMPOUND_IMPORT_FLASH_LOAN to pull _cCollateralToken
/// @param _cCollateralToken Collateral we are moving to DSProxy
/// @param _cBorrowToken Borrow token we are moving to DSProxy | NatSpecSingleLine | v0.6.12+commit.27d51765 | MIT | ipfs://34c42220a035234e7357a4f4dce033d4f7741dd29565a8d77139b7fde50d3c09 | {
"func_code_index": [
807,
1474
]
} | 3,595 |
AaveImport | contracts/compound/import/CompoundImportTaker.sol | 0x751961666d8605af1c5ee549205f822f47b04168 | Solidity | CompoundImportTaker | contract CompoundImportTaker is CompoundSaverHelper, ProxyPermission, GasBurner {
ILendingPool public constant lendingPool = ILendingPool(0x398eC7346DcD622eDc5ae82352F02bE94C62d119);
address payable public constant COMPOUND_IMPORT_FLASH_LOAN = 0xaf9f8781A4c39Ce2122019fC05F22e3a662B0A32;
address public constant PROXY_REGISTRY_ADDRESS = 0x4678f0a6958e4D2Bc4F1BAF7Bc52E8F3564f3fE4;
DefisaverLogger public constant logger = DefisaverLogger(0x5c55B921f590a89C1Ebe84dF170E655a82b62126);
/// @notice Starts the process to move users position 1 collateral and 1 borrow
/// @dev User must approve COMPOUND_IMPORT_FLASH_LOAN to pull _cCollateralToken
/// @param _cCollateralToken Collateral we are moving to DSProxy
/// @param _cBorrowToken Borrow token we are moving to DSProxy
function importLoan(address _cCollateralToken, address _cBorrowToken) external burnGas(20) {
address proxy = getProxy();
uint loanAmount = CTokenInterface(_cBorrowToken).borrowBalanceCurrent(msg.sender);
bytes memory paramsData = abi.encode(_cCollateralToken, _cBorrowToken, msg.sender, proxy);
givePermission(COMPOUND_IMPORT_FLASH_LOAN);
lendingPool.flashLoan(COMPOUND_IMPORT_FLASH_LOAN, getUnderlyingAddr(_cBorrowToken), loanAmount, paramsData);
removePermission(COMPOUND_IMPORT_FLASH_LOAN);
logger.Log(address(this), msg.sender, "CompoundImport", abi.encode(loanAmount, 0, _cCollateralToken));
}
/// @notice Gets proxy address, if user doesn't has DSProxy build it
/// @return proxy DsProxy address
function getProxy() internal returns (address proxy) {
proxy = ProxyRegistryInterface(PROXY_REGISTRY_ADDRESS).proxies(msg.sender);
if (proxy == address(0)) {
proxy = ProxyRegistryInterface(PROXY_REGISTRY_ADDRESS).build(msg.sender);
}
}
} | /// @title Imports Compound position from the account to DSProxy | NatSpecSingleLine | getProxy | function getProxy() internal returns (address proxy) {
proxy = ProxyRegistryInterface(PROXY_REGISTRY_ADDRESS).proxies(msg.sender);
if (proxy == address(0)) {
proxy = ProxyRegistryInterface(PROXY_REGISTRY_ADDRESS).build(msg.sender);
}
}
| /// @notice Gets proxy address, if user doesn't has DSProxy build it
/// @return proxy DsProxy address | NatSpecSingleLine | v0.6.12+commit.27d51765 | MIT | ipfs://34c42220a035234e7357a4f4dce033d4f7741dd29565a8d77139b7fde50d3c09 | {
"func_code_index": [
1587,
1868
]
} | 3,596 |
LPB | LPB.sol | 0xe2f10801ba34935259dbe73edb756a196279bc3c | Solidity | Ownable | contract Ownable {
address public owner;
event OwnershipRenounced(address indexed previousOwner);
event OwnershipTransferred(
address indexed previousOwner,
address indexed newOwner
);
/**
* @dev The Ownable constructor sets the original `owner` of the contract to the
sender
* account.
*/
constructor() public {
owner = msg.sender;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(msg.sender == owner);
_;
}
/**
* @dev Allows the current owner to transfer control of the contract to a newOwner.
* @param newOwner The address to transfer ownership to.
*/
function transferOwnership(address newOwner) public onlyOwner {
require(newOwner != address(0));
emit OwnershipTransferred(owner, newOwner);
owner = newOwner;
}
/**
* @dev Allows the current owner to relinquish control of the contract.
*/
function renounceOwnership() public onlyOwner {
emit OwnershipRenounced(owner);
owner = address(0);
}
} | /**
* @title Ownable
* @dev The Ownable contract has an owner address, and provides basic authorization
control
* functions, this simplifies the implementation of "user permissions".
*/ | NatSpecMultiLine | transferOwnership | function transferOwnership(address newOwner) public onlyOwner {
require(newOwner != address(0));
emit OwnershipTransferred(owner, newOwner);
owner = newOwner;
}
| /**
* @dev Allows the current owner to transfer control of the contract to a newOwner.
* @param newOwner The address to transfer ownership to.
*/ | NatSpecMultiLine | v0.4.23+commit.124ca40d | None | bzzr://fb49ca9ca41253408a485ab8cd21ff66618173d4e5f6bbf0e51bff5cd9196cc1 | {
"func_code_index": [
633,
798
]
} | 3,597 |
LPB | LPB.sol | 0xe2f10801ba34935259dbe73edb756a196279bc3c | Solidity | Ownable | contract Ownable {
address public owner;
event OwnershipRenounced(address indexed previousOwner);
event OwnershipTransferred(
address indexed previousOwner,
address indexed newOwner
);
/**
* @dev The Ownable constructor sets the original `owner` of the contract to the
sender
* account.
*/
constructor() public {
owner = msg.sender;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(msg.sender == owner);
_;
}
/**
* @dev Allows the current owner to transfer control of the contract to a newOwner.
* @param newOwner The address to transfer ownership to.
*/
function transferOwnership(address newOwner) public onlyOwner {
require(newOwner != address(0));
emit OwnershipTransferred(owner, newOwner);
owner = newOwner;
}
/**
* @dev Allows the current owner to relinquish control of the contract.
*/
function renounceOwnership() public onlyOwner {
emit OwnershipRenounced(owner);
owner = address(0);
}
} | /**
* @title Ownable
* @dev The Ownable contract has an owner address, and provides basic authorization
control
* functions, this simplifies the implementation of "user permissions".
*/ | NatSpecMultiLine | renounceOwnership | function renounceOwnership() public onlyOwner {
emit OwnershipRenounced(owner);
owner = address(0);
}
| /**
* @dev Allows the current owner to relinquish control of the contract.
*/ | NatSpecMultiLine | v0.4.23+commit.124ca40d | None | bzzr://fb49ca9ca41253408a485ab8cd21ff66618173d4e5f6bbf0e51bff5cd9196cc1 | {
"func_code_index": [
880,
985
]
} | 3,598 |
LPB | LPB.sol | 0xe2f10801ba34935259dbe73edb756a196279bc3c | Solidity | SafeMath | library SafeMath {
/**
* @dev Multiplies two numbers, throws on overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256 c) {
if (a == 0) {
return 0;
}
c = a * b;
assert(c / a == b);
return c;
}
/**
* @dev Integer division of two numbers, truncating the quotient.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
// assert(b > 0); // Solidity automatically throws 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 a / b;
}
/**
* @dev Subtracts two numbers, throws on overflow (i.e. if subtrahend is greater than
minuend).
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
assert(b <= a);
return a - b;
}
/**
* @dev Adds two numbers, throws on overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256 c) {
c = a + b;
assert(c >= a);
return c;
}
} | /**
* @title SafeMath
* @dev Math operations with safety checks that throw on error
*/ | NatSpecMultiLine | mul | function mul(uint256 a, uint256 b) internal pure returns (uint256 c) {
if (a == 0) {
return 0;
}
c = a * b;
assert(c / a == b);
return c;
}
| /**
* @dev Multiplies two numbers, throws on overflow.
*/ | NatSpecMultiLine | v0.4.23+commit.124ca40d | None | bzzr://fb49ca9ca41253408a485ab8cd21ff66618173d4e5f6bbf0e51bff5cd9196cc1 | {
"func_code_index": [
81,
228
]
} | 3,599 |
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.