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
VaultRouter
VaultRouter.sol
0x9e9f4b105e10a66b27c771811ce4defbd44567d2
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) { // This method relies in extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; // solhint-disable-next-line no-inline-assembly assembly { size := extcodesize(account) } return size > 0; } /** * @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); } } } }
/** * @dev Collection of functions related to the address type */
NatSpecMultiLine
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.8.4+commit.c7e474f2
MIT
ipfs://38ce5c6af5f119df33d6c128c761796ed6341eb5d78756f5cf54835a34958588
{ "func_code_index": [ 3546, 3781 ] }
407
VaultRouter
VaultRouter.sol
0x9e9f4b105e10a66b27c771811ce4defbd44567d2
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) { // This method relies in extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; // solhint-disable-next-line no-inline-assembly assembly { size := extcodesize(account) } return size > 0; } /** * @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); } } } }
/** * @dev Collection of functions related to the address type */
NatSpecMultiLine
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.8.4+commit.c7e474f2
MIT
ipfs://38ce5c6af5f119df33d6c128c761796ed6341eb5d78756f5cf54835a34958588
{ "func_code_index": [ 4151, 4416 ] }
408
VaultRouter
VaultRouter.sol
0x9e9f4b105e10a66b27c771811ce4defbd44567d2
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) { // This method relies in extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; // solhint-disable-next-line no-inline-assembly assembly { size := extcodesize(account) } return size > 0; } /** * @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); } } } }
/** * @dev Collection of functions related to the address type */
NatSpecMultiLine
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.8.4+commit.c7e474f2
MIT
ipfs://38ce5c6af5f119df33d6c128c761796ed6341eb5d78756f5cf54835a34958588
{ "func_code_index": [ 4667, 5031 ] }
409
VaultRouter
VaultRouter.sol
0x9e9f4b105e10a66b27c771811ce4defbd44567d2
Solidity
BaseFallback
contract BaseFallback is Fallback { /** * @dev Contract constructor. * @param _logic Address of the initial implementation. * @param _data Data to send as msg.data to the implementation to initialize the proxied contract. * It should include the signature and the parameters of the function to be called, as described in * https://solidity.readthedocs.io/en/v0.4.24/abi-spec.html#function-selector-and-argument-encoding. * This parameter is optional, if no data is given the initialization call to proxied contract will be skipped. */ constructor(address _logic, bytes memory _data) payable { assert(IMPLEMENTATION_SLOT == bytes32(uint256(keccak256("eip1967.proxy.implementation")) - 1)); _setImplementation(_logic); if (_data.length > 0) { (bool success, ) = _logic.delegatecall(_data); require(success); } } /** * @dev Emitted when the implementation is upgraded. * @param implementation Address of the new implementation. */ event Upgraded(address indexed implementation); /** * @dev Storage slot with the address of the current implementation. * This is the keccak-256 hash of "eip1967.proxy.implementation" subtracted by 1, and is * validated in the constructor. */ bytes32 internal constant IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc; /** * @dev Returns the current implementation. * @return impl Address of the current implementation */ function _implementation() internal view override returns (address impl) { bytes32 slot = IMPLEMENTATION_SLOT; assembly { impl := sload(slot) } } /** * @dev Upgrades the to a new implementation. * @param newImplementation Address of the new implementation. */ function _upgradeTo(address newImplementation) internal { _setImplementation(newImplementation); emit Upgraded(newImplementation); } /** * @dev Sets the implementation address of the. * @param newImplementation Address of the new implementation. */ function _setImplementation(address newImplementation) internal { require(Address.isContract(newImplementation), "Cannot set a implementation to a non-contract address"); bytes32 slot = IMPLEMENTATION_SLOT; assembly { sstore(slot, newImplementation) } } }
/** * @title BaseFallback * @dev This contract implements a proxy that allows to change the * implementation address to which it will delegate. * Such a change is called an implementation upgrade. */
NatSpecMultiLine
_implementation
function _implementation() internal view override returns (address impl) { bytes32 slot = IMPLEMENTATION_SLOT; assembly { impl := sload(slot) } }
/** * @dev Returns the current implementation. * @return impl Address of the current implementation */
NatSpecMultiLine
v0.8.4+commit.c7e474f2
MIT
ipfs://38ce5c6af5f119df33d6c128c761796ed6341eb5d78756f5cf54835a34958588
{ "func_code_index": [ 1601, 1796 ] }
410
VaultRouter
VaultRouter.sol
0x9e9f4b105e10a66b27c771811ce4defbd44567d2
Solidity
BaseFallback
contract BaseFallback is Fallback { /** * @dev Contract constructor. * @param _logic Address of the initial implementation. * @param _data Data to send as msg.data to the implementation to initialize the proxied contract. * It should include the signature and the parameters of the function to be called, as described in * https://solidity.readthedocs.io/en/v0.4.24/abi-spec.html#function-selector-and-argument-encoding. * This parameter is optional, if no data is given the initialization call to proxied contract will be skipped. */ constructor(address _logic, bytes memory _data) payable { assert(IMPLEMENTATION_SLOT == bytes32(uint256(keccak256("eip1967.proxy.implementation")) - 1)); _setImplementation(_logic); if (_data.length > 0) { (bool success, ) = _logic.delegatecall(_data); require(success); } } /** * @dev Emitted when the implementation is upgraded. * @param implementation Address of the new implementation. */ event Upgraded(address indexed implementation); /** * @dev Storage slot with the address of the current implementation. * This is the keccak-256 hash of "eip1967.proxy.implementation" subtracted by 1, and is * validated in the constructor. */ bytes32 internal constant IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc; /** * @dev Returns the current implementation. * @return impl Address of the current implementation */ function _implementation() internal view override returns (address impl) { bytes32 slot = IMPLEMENTATION_SLOT; assembly { impl := sload(slot) } } /** * @dev Upgrades the to a new implementation. * @param newImplementation Address of the new implementation. */ function _upgradeTo(address newImplementation) internal { _setImplementation(newImplementation); emit Upgraded(newImplementation); } /** * @dev Sets the implementation address of the. * @param newImplementation Address of the new implementation. */ function _setImplementation(address newImplementation) internal { require(Address.isContract(newImplementation), "Cannot set a implementation to a non-contract address"); bytes32 slot = IMPLEMENTATION_SLOT; assembly { sstore(slot, newImplementation) } } }
/** * @title BaseFallback * @dev This contract implements a proxy that allows to change the * implementation address to which it will delegate. * Such a change is called an implementation upgrade. */
NatSpecMultiLine
_upgradeTo
function _upgradeTo(address newImplementation) internal { _setImplementation(newImplementation); emit Upgraded(newImplementation); }
/** * @dev Upgrades the to a new implementation. * @param newImplementation Address of the new implementation. */
NatSpecMultiLine
v0.8.4+commit.c7e474f2
MIT
ipfs://38ce5c6af5f119df33d6c128c761796ed6341eb5d78756f5cf54835a34958588
{ "func_code_index": [ 1936, 2096 ] }
411
VaultRouter
VaultRouter.sol
0x9e9f4b105e10a66b27c771811ce4defbd44567d2
Solidity
BaseFallback
contract BaseFallback is Fallback { /** * @dev Contract constructor. * @param _logic Address of the initial implementation. * @param _data Data to send as msg.data to the implementation to initialize the proxied contract. * It should include the signature and the parameters of the function to be called, as described in * https://solidity.readthedocs.io/en/v0.4.24/abi-spec.html#function-selector-and-argument-encoding. * This parameter is optional, if no data is given the initialization call to proxied contract will be skipped. */ constructor(address _logic, bytes memory _data) payable { assert(IMPLEMENTATION_SLOT == bytes32(uint256(keccak256("eip1967.proxy.implementation")) - 1)); _setImplementation(_logic); if (_data.length > 0) { (bool success, ) = _logic.delegatecall(_data); require(success); } } /** * @dev Emitted when the implementation is upgraded. * @param implementation Address of the new implementation. */ event Upgraded(address indexed implementation); /** * @dev Storage slot with the address of the current implementation. * This is the keccak-256 hash of "eip1967.proxy.implementation" subtracted by 1, and is * validated in the constructor. */ bytes32 internal constant IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc; /** * @dev Returns the current implementation. * @return impl Address of the current implementation */ function _implementation() internal view override returns (address impl) { bytes32 slot = IMPLEMENTATION_SLOT; assembly { impl := sload(slot) } } /** * @dev Upgrades the to a new implementation. * @param newImplementation Address of the new implementation. */ function _upgradeTo(address newImplementation) internal { _setImplementation(newImplementation); emit Upgraded(newImplementation); } /** * @dev Sets the implementation address of the. * @param newImplementation Address of the new implementation. */ function _setImplementation(address newImplementation) internal { require(Address.isContract(newImplementation), "Cannot set a implementation to a non-contract address"); bytes32 slot = IMPLEMENTATION_SLOT; assembly { sstore(slot, newImplementation) } } }
/** * @title BaseFallback * @dev This contract implements a proxy that allows to change the * implementation address to which it will delegate. * Such a change is called an implementation upgrade. */
NatSpecMultiLine
_setImplementation
function _setImplementation(address newImplementation) internal { require(Address.isContract(newImplementation), "Cannot set a implementation to a non-contract address"); bytes32 slot = IMPLEMENTATION_SLOT; assembly { sstore(slot, newImplementation) } }
/** * @dev Sets the implementation address of the. * @param newImplementation Address of the new implementation. */
NatSpecMultiLine
v0.8.4+commit.c7e474f2
MIT
ipfs://38ce5c6af5f119df33d6c128c761796ed6341eb5d78756f5cf54835a34958588
{ "func_code_index": [ 2238, 2554 ] }
412
VaultRouter
VaultRouter.sol
0x9e9f4b105e10a66b27c771811ce4defbd44567d2
Solidity
VaultRouter
contract VaultRouter is BaseFallback { /** * Contract constructor. * @param _logic address of the initial implementation. * @param _admin_ Address of the administrator. * @param _data Data to send as msg.data to the implementation to initialize the proxied contract. * It should include the signature and the parameters of the function to be called, as described in * https://solidity.readthedocs.io/en/v0.4.24/abi-spec.html#function-selector-and-argument-encoding. * This parameter is optional, if no data is given the initialization call to proxied contract will be skipped. */ constructor( address _logic, address _admin_, bytes memory _data ) payable BaseFallback(_logic, _data) { assert(ADMIN_SLOT == bytes32(uint256(keccak256("eip1967.proxy.admin")) - 1)); _setAdmin(_admin_); } /** * @dev Emitted when the administration has been transferred. * @param previousAdmin Address of the previous admin. * @param newAdmin Address of the new admin. */ event AdminChanged(address previousAdmin, address newAdmin); /** * @dev Storage slot with the admin of the contract. * This is the keccak-256 hash of "eip1967.proxy.admin" subtracted by 1, and is * validated in the constructor. */ bytes32 internal constant ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103; /** * @dev Modifier to check whether the `msg.sender` is the admin. * If it is, it will run the function. Otherwise, it will delegate the call * to the implementation. */ modifier ifAdmin() { if (msg.sender == _admin()) { _; } else { _fallback(); } } /** * @return addr The address of the admin. */ function admin() external ifAdmin returns (address addr) { addr = _admin(); } /** * @return addr The address of the implementation. */ function implementation() external ifAdmin returns (address addr) { addr = _implementation(); } /** * @dev Changes the admin of the. * Only the current admin can call this function. * @param newAdmin Address to transfer administration to. */ function changeAdmin(address newAdmin) external ifAdmin { require(newAdmin != address(0), "Cannot change the admin of a proxy to the zero address"); emit AdminChanged(_admin(), newAdmin); _setAdmin(newAdmin); } /** * @dev Upgrade the backing implementation of the proxy. * Only the admin can call this function. * @param newImplementation Address of the new implementation. */ function upgradeTo(address newImplementation) external ifAdmin { _upgradeTo(newImplementation); } /** * @dev Upgrade the backing implementation of the proxy and call a function * on the new implementation. * This is useful to initialize the proxied contract. * @param newImplementation Address of the new implementation. * @param data Data to send as msg.data in the low level call. * It should include the signature and the parameters of the function to be called, as described in * https://solidity.readthedocs.io/en/v0.4.24/abi-spec.html#function-selector-and-argument-encoding. */ function upgradeToAndCall(address newImplementation, bytes calldata data) external payable ifAdmin { _upgradeTo(newImplementation); (bool success, ) = newImplementation.delegatecall(data); require(success); } /** * @return adm The admin slot. */ function _admin() internal view returns (address adm) { bytes32 slot = ADMIN_SLOT; assembly { adm := sload(slot) } } /** * @dev Sets the address of the proxy admin. * @param newAdmin Address of the new proxy admin. */ function _setAdmin(address newAdmin) internal { bytes32 slot = ADMIN_SLOT; assembly { sstore(slot, newAdmin) } } /** * @dev Only fall back when the sender is not the admin. */ function _willFallback() internal virtual override { require(msg.sender != _admin(), "Cannot call fallback function from the proxy admin"); super._willFallback(); } }
/** * @title VaultRouter * @dev This contract combines an upgradeability with an authorization * mechanism for administrative tasks. * All external functions in this contract must be guarded by the * `ifAdmin` modifier. See ethereum/solidity#3864 for a Solidity * feature proposal that would enable this to be done automatically. */
NatSpecMultiLine
admin
function admin() external ifAdmin returns (address addr) { addr = _admin(); }
/** * @return addr The address of the admin. */
NatSpecMultiLine
v0.8.4+commit.c7e474f2
MIT
ipfs://38ce5c6af5f119df33d6c128c761796ed6341eb5d78756f5cf54835a34958588
{ "func_code_index": [ 1889, 1985 ] }
413
VaultRouter
VaultRouter.sol
0x9e9f4b105e10a66b27c771811ce4defbd44567d2
Solidity
VaultRouter
contract VaultRouter is BaseFallback { /** * Contract constructor. * @param _logic address of the initial implementation. * @param _admin_ Address of the administrator. * @param _data Data to send as msg.data to the implementation to initialize the proxied contract. * It should include the signature and the parameters of the function to be called, as described in * https://solidity.readthedocs.io/en/v0.4.24/abi-spec.html#function-selector-and-argument-encoding. * This parameter is optional, if no data is given the initialization call to proxied contract will be skipped. */ constructor( address _logic, address _admin_, bytes memory _data ) payable BaseFallback(_logic, _data) { assert(ADMIN_SLOT == bytes32(uint256(keccak256("eip1967.proxy.admin")) - 1)); _setAdmin(_admin_); } /** * @dev Emitted when the administration has been transferred. * @param previousAdmin Address of the previous admin. * @param newAdmin Address of the new admin. */ event AdminChanged(address previousAdmin, address newAdmin); /** * @dev Storage slot with the admin of the contract. * This is the keccak-256 hash of "eip1967.proxy.admin" subtracted by 1, and is * validated in the constructor. */ bytes32 internal constant ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103; /** * @dev Modifier to check whether the `msg.sender` is the admin. * If it is, it will run the function. Otherwise, it will delegate the call * to the implementation. */ modifier ifAdmin() { if (msg.sender == _admin()) { _; } else { _fallback(); } } /** * @return addr The address of the admin. */ function admin() external ifAdmin returns (address addr) { addr = _admin(); } /** * @return addr The address of the implementation. */ function implementation() external ifAdmin returns (address addr) { addr = _implementation(); } /** * @dev Changes the admin of the. * Only the current admin can call this function. * @param newAdmin Address to transfer administration to. */ function changeAdmin(address newAdmin) external ifAdmin { require(newAdmin != address(0), "Cannot change the admin of a proxy to the zero address"); emit AdminChanged(_admin(), newAdmin); _setAdmin(newAdmin); } /** * @dev Upgrade the backing implementation of the proxy. * Only the admin can call this function. * @param newImplementation Address of the new implementation. */ function upgradeTo(address newImplementation) external ifAdmin { _upgradeTo(newImplementation); } /** * @dev Upgrade the backing implementation of the proxy and call a function * on the new implementation. * This is useful to initialize the proxied contract. * @param newImplementation Address of the new implementation. * @param data Data to send as msg.data in the low level call. * It should include the signature and the parameters of the function to be called, as described in * https://solidity.readthedocs.io/en/v0.4.24/abi-spec.html#function-selector-and-argument-encoding. */ function upgradeToAndCall(address newImplementation, bytes calldata data) external payable ifAdmin { _upgradeTo(newImplementation); (bool success, ) = newImplementation.delegatecall(data); require(success); } /** * @return adm The admin slot. */ function _admin() internal view returns (address adm) { bytes32 slot = ADMIN_SLOT; assembly { adm := sload(slot) } } /** * @dev Sets the address of the proxy admin. * @param newAdmin Address of the new proxy admin. */ function _setAdmin(address newAdmin) internal { bytes32 slot = ADMIN_SLOT; assembly { sstore(slot, newAdmin) } } /** * @dev Only fall back when the sender is not the admin. */ function _willFallback() internal virtual override { require(msg.sender != _admin(), "Cannot call fallback function from the proxy admin"); super._willFallback(); } }
/** * @title VaultRouter * @dev This contract combines an upgradeability with an authorization * mechanism for administrative tasks. * All external functions in this contract must be guarded by the * `ifAdmin` modifier. See ethereum/solidity#3864 for a Solidity * feature proposal that would enable this to be done automatically. */
NatSpecMultiLine
implementation
function implementation() external ifAdmin returns (address addr) { addr = _implementation(); }
/** * @return addr The address of the implementation. */
NatSpecMultiLine
v0.8.4+commit.c7e474f2
MIT
ipfs://38ce5c6af5f119df33d6c128c761796ed6341eb5d78756f5cf54835a34958588
{ "func_code_index": [ 2062, 2176 ] }
414
VaultRouter
VaultRouter.sol
0x9e9f4b105e10a66b27c771811ce4defbd44567d2
Solidity
VaultRouter
contract VaultRouter is BaseFallback { /** * Contract constructor. * @param _logic address of the initial implementation. * @param _admin_ Address of the administrator. * @param _data Data to send as msg.data to the implementation to initialize the proxied contract. * It should include the signature and the parameters of the function to be called, as described in * https://solidity.readthedocs.io/en/v0.4.24/abi-spec.html#function-selector-and-argument-encoding. * This parameter is optional, if no data is given the initialization call to proxied contract will be skipped. */ constructor( address _logic, address _admin_, bytes memory _data ) payable BaseFallback(_logic, _data) { assert(ADMIN_SLOT == bytes32(uint256(keccak256("eip1967.proxy.admin")) - 1)); _setAdmin(_admin_); } /** * @dev Emitted when the administration has been transferred. * @param previousAdmin Address of the previous admin. * @param newAdmin Address of the new admin. */ event AdminChanged(address previousAdmin, address newAdmin); /** * @dev Storage slot with the admin of the contract. * This is the keccak-256 hash of "eip1967.proxy.admin" subtracted by 1, and is * validated in the constructor. */ bytes32 internal constant ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103; /** * @dev Modifier to check whether the `msg.sender` is the admin. * If it is, it will run the function. Otherwise, it will delegate the call * to the implementation. */ modifier ifAdmin() { if (msg.sender == _admin()) { _; } else { _fallback(); } } /** * @return addr The address of the admin. */ function admin() external ifAdmin returns (address addr) { addr = _admin(); } /** * @return addr The address of the implementation. */ function implementation() external ifAdmin returns (address addr) { addr = _implementation(); } /** * @dev Changes the admin of the. * Only the current admin can call this function. * @param newAdmin Address to transfer administration to. */ function changeAdmin(address newAdmin) external ifAdmin { require(newAdmin != address(0), "Cannot change the admin of a proxy to the zero address"); emit AdminChanged(_admin(), newAdmin); _setAdmin(newAdmin); } /** * @dev Upgrade the backing implementation of the proxy. * Only the admin can call this function. * @param newImplementation Address of the new implementation. */ function upgradeTo(address newImplementation) external ifAdmin { _upgradeTo(newImplementation); } /** * @dev Upgrade the backing implementation of the proxy and call a function * on the new implementation. * This is useful to initialize the proxied contract. * @param newImplementation Address of the new implementation. * @param data Data to send as msg.data in the low level call. * It should include the signature and the parameters of the function to be called, as described in * https://solidity.readthedocs.io/en/v0.4.24/abi-spec.html#function-selector-and-argument-encoding. */ function upgradeToAndCall(address newImplementation, bytes calldata data) external payable ifAdmin { _upgradeTo(newImplementation); (bool success, ) = newImplementation.delegatecall(data); require(success); } /** * @return adm The admin slot. */ function _admin() internal view returns (address adm) { bytes32 slot = ADMIN_SLOT; assembly { adm := sload(slot) } } /** * @dev Sets the address of the proxy admin. * @param newAdmin Address of the new proxy admin. */ function _setAdmin(address newAdmin) internal { bytes32 slot = ADMIN_SLOT; assembly { sstore(slot, newAdmin) } } /** * @dev Only fall back when the sender is not the admin. */ function _willFallback() internal virtual override { require(msg.sender != _admin(), "Cannot call fallback function from the proxy admin"); super._willFallback(); } }
/** * @title VaultRouter * @dev This contract combines an upgradeability with an authorization * mechanism for administrative tasks. * All external functions in this contract must be guarded by the * `ifAdmin` modifier. See ethereum/solidity#3864 for a Solidity * feature proposal that would enable this to be done automatically. */
NatSpecMultiLine
changeAdmin
function changeAdmin(address newAdmin) external ifAdmin { require(newAdmin != address(0), "Cannot change the admin of a proxy to the zero address"); emit AdminChanged(_admin(), newAdmin); _setAdmin(newAdmin); }
/** * @dev Changes the admin of the. * Only the current admin can call this function. * @param newAdmin Address to transfer administration to. */
NatSpecMultiLine
v0.8.4+commit.c7e474f2
MIT
ipfs://38ce5c6af5f119df33d6c128c761796ed6341eb5d78756f5cf54835a34958588
{ "func_code_index": [ 2354, 2601 ] }
415
VaultRouter
VaultRouter.sol
0x9e9f4b105e10a66b27c771811ce4defbd44567d2
Solidity
VaultRouter
contract VaultRouter is BaseFallback { /** * Contract constructor. * @param _logic address of the initial implementation. * @param _admin_ Address of the administrator. * @param _data Data to send as msg.data to the implementation to initialize the proxied contract. * It should include the signature and the parameters of the function to be called, as described in * https://solidity.readthedocs.io/en/v0.4.24/abi-spec.html#function-selector-and-argument-encoding. * This parameter is optional, if no data is given the initialization call to proxied contract will be skipped. */ constructor( address _logic, address _admin_, bytes memory _data ) payable BaseFallback(_logic, _data) { assert(ADMIN_SLOT == bytes32(uint256(keccak256("eip1967.proxy.admin")) - 1)); _setAdmin(_admin_); } /** * @dev Emitted when the administration has been transferred. * @param previousAdmin Address of the previous admin. * @param newAdmin Address of the new admin. */ event AdminChanged(address previousAdmin, address newAdmin); /** * @dev Storage slot with the admin of the contract. * This is the keccak-256 hash of "eip1967.proxy.admin" subtracted by 1, and is * validated in the constructor. */ bytes32 internal constant ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103; /** * @dev Modifier to check whether the `msg.sender` is the admin. * If it is, it will run the function. Otherwise, it will delegate the call * to the implementation. */ modifier ifAdmin() { if (msg.sender == _admin()) { _; } else { _fallback(); } } /** * @return addr The address of the admin. */ function admin() external ifAdmin returns (address addr) { addr = _admin(); } /** * @return addr The address of the implementation. */ function implementation() external ifAdmin returns (address addr) { addr = _implementation(); } /** * @dev Changes the admin of the. * Only the current admin can call this function. * @param newAdmin Address to transfer administration to. */ function changeAdmin(address newAdmin) external ifAdmin { require(newAdmin != address(0), "Cannot change the admin of a proxy to the zero address"); emit AdminChanged(_admin(), newAdmin); _setAdmin(newAdmin); } /** * @dev Upgrade the backing implementation of the proxy. * Only the admin can call this function. * @param newImplementation Address of the new implementation. */ function upgradeTo(address newImplementation) external ifAdmin { _upgradeTo(newImplementation); } /** * @dev Upgrade the backing implementation of the proxy and call a function * on the new implementation. * This is useful to initialize the proxied contract. * @param newImplementation Address of the new implementation. * @param data Data to send as msg.data in the low level call. * It should include the signature and the parameters of the function to be called, as described in * https://solidity.readthedocs.io/en/v0.4.24/abi-spec.html#function-selector-and-argument-encoding. */ function upgradeToAndCall(address newImplementation, bytes calldata data) external payable ifAdmin { _upgradeTo(newImplementation); (bool success, ) = newImplementation.delegatecall(data); require(success); } /** * @return adm The admin slot. */ function _admin() internal view returns (address adm) { bytes32 slot = ADMIN_SLOT; assembly { adm := sload(slot) } } /** * @dev Sets the address of the proxy admin. * @param newAdmin Address of the new proxy admin. */ function _setAdmin(address newAdmin) internal { bytes32 slot = ADMIN_SLOT; assembly { sstore(slot, newAdmin) } } /** * @dev Only fall back when the sender is not the admin. */ function _willFallback() internal virtual override { require(msg.sender != _admin(), "Cannot call fallback function from the proxy admin"); super._willFallback(); } }
/** * @title VaultRouter * @dev This contract combines an upgradeability with an authorization * mechanism for administrative tasks. * All external functions in this contract must be guarded by the * `ifAdmin` modifier. See ethereum/solidity#3864 for a Solidity * feature proposal that would enable this to be done automatically. */
NatSpecMultiLine
upgradeTo
function upgradeTo(address newImplementation) external ifAdmin { _upgradeTo(newImplementation); }
/** * @dev Upgrade the backing implementation of the proxy. * Only the admin can call this function. * @param newImplementation Address of the new implementation. */
NatSpecMultiLine
v0.8.4+commit.c7e474f2
MIT
ipfs://38ce5c6af5f119df33d6c128c761796ed6341eb5d78756f5cf54835a34958588
{ "func_code_index": [ 2799, 2915 ] }
416
VaultRouter
VaultRouter.sol
0x9e9f4b105e10a66b27c771811ce4defbd44567d2
Solidity
VaultRouter
contract VaultRouter is BaseFallback { /** * Contract constructor. * @param _logic address of the initial implementation. * @param _admin_ Address of the administrator. * @param _data Data to send as msg.data to the implementation to initialize the proxied contract. * It should include the signature and the parameters of the function to be called, as described in * https://solidity.readthedocs.io/en/v0.4.24/abi-spec.html#function-selector-and-argument-encoding. * This parameter is optional, if no data is given the initialization call to proxied contract will be skipped. */ constructor( address _logic, address _admin_, bytes memory _data ) payable BaseFallback(_logic, _data) { assert(ADMIN_SLOT == bytes32(uint256(keccak256("eip1967.proxy.admin")) - 1)); _setAdmin(_admin_); } /** * @dev Emitted when the administration has been transferred. * @param previousAdmin Address of the previous admin. * @param newAdmin Address of the new admin. */ event AdminChanged(address previousAdmin, address newAdmin); /** * @dev Storage slot with the admin of the contract. * This is the keccak-256 hash of "eip1967.proxy.admin" subtracted by 1, and is * validated in the constructor. */ bytes32 internal constant ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103; /** * @dev Modifier to check whether the `msg.sender` is the admin. * If it is, it will run the function. Otherwise, it will delegate the call * to the implementation. */ modifier ifAdmin() { if (msg.sender == _admin()) { _; } else { _fallback(); } } /** * @return addr The address of the admin. */ function admin() external ifAdmin returns (address addr) { addr = _admin(); } /** * @return addr The address of the implementation. */ function implementation() external ifAdmin returns (address addr) { addr = _implementation(); } /** * @dev Changes the admin of the. * Only the current admin can call this function. * @param newAdmin Address to transfer administration to. */ function changeAdmin(address newAdmin) external ifAdmin { require(newAdmin != address(0), "Cannot change the admin of a proxy to the zero address"); emit AdminChanged(_admin(), newAdmin); _setAdmin(newAdmin); } /** * @dev Upgrade the backing implementation of the proxy. * Only the admin can call this function. * @param newImplementation Address of the new implementation. */ function upgradeTo(address newImplementation) external ifAdmin { _upgradeTo(newImplementation); } /** * @dev Upgrade the backing implementation of the proxy and call a function * on the new implementation. * This is useful to initialize the proxied contract. * @param newImplementation Address of the new implementation. * @param data Data to send as msg.data in the low level call. * It should include the signature and the parameters of the function to be called, as described in * https://solidity.readthedocs.io/en/v0.4.24/abi-spec.html#function-selector-and-argument-encoding. */ function upgradeToAndCall(address newImplementation, bytes calldata data) external payable ifAdmin { _upgradeTo(newImplementation); (bool success, ) = newImplementation.delegatecall(data); require(success); } /** * @return adm The admin slot. */ function _admin() internal view returns (address adm) { bytes32 slot = ADMIN_SLOT; assembly { adm := sload(slot) } } /** * @dev Sets the address of the proxy admin. * @param newAdmin Address of the new proxy admin. */ function _setAdmin(address newAdmin) internal { bytes32 slot = ADMIN_SLOT; assembly { sstore(slot, newAdmin) } } /** * @dev Only fall back when the sender is not the admin. */ function _willFallback() internal virtual override { require(msg.sender != _admin(), "Cannot call fallback function from the proxy admin"); super._willFallback(); } }
/** * @title VaultRouter * @dev This contract combines an upgradeability with an authorization * mechanism for administrative tasks. * All external functions in this contract must be guarded by the * `ifAdmin` modifier. See ethereum/solidity#3864 for a Solidity * feature proposal that would enable this to be done automatically. */
NatSpecMultiLine
upgradeToAndCall
function upgradeToAndCall(address newImplementation, bytes calldata data) external payable ifAdmin { _upgradeTo(newImplementation); (bool success, ) = newImplementation.delegatecall(data); require(success); }
/** * @dev Upgrade the backing implementation of the proxy and call a function * on the new implementation. * This is useful to initialize the proxied contract. * @param newImplementation Address of the new implementation. * @param data Data to send as msg.data in the low level call. * It should include the signature and the parameters of the function to be called, as described in * https://solidity.readthedocs.io/en/v0.4.24/abi-spec.html#function-selector-and-argument-encoding. */
NatSpecMultiLine
v0.8.4+commit.c7e474f2
MIT
ipfs://38ce5c6af5f119df33d6c128c761796ed6341eb5d78756f5cf54835a34958588
{ "func_code_index": [ 3458, 3703 ] }
417
VaultRouter
VaultRouter.sol
0x9e9f4b105e10a66b27c771811ce4defbd44567d2
Solidity
VaultRouter
contract VaultRouter is BaseFallback { /** * Contract constructor. * @param _logic address of the initial implementation. * @param _admin_ Address of the administrator. * @param _data Data to send as msg.data to the implementation to initialize the proxied contract. * It should include the signature and the parameters of the function to be called, as described in * https://solidity.readthedocs.io/en/v0.4.24/abi-spec.html#function-selector-and-argument-encoding. * This parameter is optional, if no data is given the initialization call to proxied contract will be skipped. */ constructor( address _logic, address _admin_, bytes memory _data ) payable BaseFallback(_logic, _data) { assert(ADMIN_SLOT == bytes32(uint256(keccak256("eip1967.proxy.admin")) - 1)); _setAdmin(_admin_); } /** * @dev Emitted when the administration has been transferred. * @param previousAdmin Address of the previous admin. * @param newAdmin Address of the new admin. */ event AdminChanged(address previousAdmin, address newAdmin); /** * @dev Storage slot with the admin of the contract. * This is the keccak-256 hash of "eip1967.proxy.admin" subtracted by 1, and is * validated in the constructor. */ bytes32 internal constant ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103; /** * @dev Modifier to check whether the `msg.sender` is the admin. * If it is, it will run the function. Otherwise, it will delegate the call * to the implementation. */ modifier ifAdmin() { if (msg.sender == _admin()) { _; } else { _fallback(); } } /** * @return addr The address of the admin. */ function admin() external ifAdmin returns (address addr) { addr = _admin(); } /** * @return addr The address of the implementation. */ function implementation() external ifAdmin returns (address addr) { addr = _implementation(); } /** * @dev Changes the admin of the. * Only the current admin can call this function. * @param newAdmin Address to transfer administration to. */ function changeAdmin(address newAdmin) external ifAdmin { require(newAdmin != address(0), "Cannot change the admin of a proxy to the zero address"); emit AdminChanged(_admin(), newAdmin); _setAdmin(newAdmin); } /** * @dev Upgrade the backing implementation of the proxy. * Only the admin can call this function. * @param newImplementation Address of the new implementation. */ function upgradeTo(address newImplementation) external ifAdmin { _upgradeTo(newImplementation); } /** * @dev Upgrade the backing implementation of the proxy and call a function * on the new implementation. * This is useful to initialize the proxied contract. * @param newImplementation Address of the new implementation. * @param data Data to send as msg.data in the low level call. * It should include the signature and the parameters of the function to be called, as described in * https://solidity.readthedocs.io/en/v0.4.24/abi-spec.html#function-selector-and-argument-encoding. */ function upgradeToAndCall(address newImplementation, bytes calldata data) external payable ifAdmin { _upgradeTo(newImplementation); (bool success, ) = newImplementation.delegatecall(data); require(success); } /** * @return adm The admin slot. */ function _admin() internal view returns (address adm) { bytes32 slot = ADMIN_SLOT; assembly { adm := sload(slot) } } /** * @dev Sets the address of the proxy admin. * @param newAdmin Address of the new proxy admin. */ function _setAdmin(address newAdmin) internal { bytes32 slot = ADMIN_SLOT; assembly { sstore(slot, newAdmin) } } /** * @dev Only fall back when the sender is not the admin. */ function _willFallback() internal virtual override { require(msg.sender != _admin(), "Cannot call fallback function from the proxy admin"); super._willFallback(); } }
/** * @title VaultRouter * @dev This contract combines an upgradeability with an authorization * mechanism for administrative tasks. * All external functions in this contract must be guarded by the * `ifAdmin` modifier. See ethereum/solidity#3864 for a Solidity * feature proposal that would enable this to be done automatically. */
NatSpecMultiLine
_admin
function _admin() internal view returns (address adm) { bytes32 slot = ADMIN_SLOT; assembly { adm := sload(slot) } }
/** * @return adm The admin slot. */
NatSpecMultiLine
v0.8.4+commit.c7e474f2
MIT
ipfs://38ce5c6af5f119df33d6c128c761796ed6341eb5d78756f5cf54835a34958588
{ "func_code_index": [ 3760, 3926 ] }
418
VaultRouter
VaultRouter.sol
0x9e9f4b105e10a66b27c771811ce4defbd44567d2
Solidity
VaultRouter
contract VaultRouter is BaseFallback { /** * Contract constructor. * @param _logic address of the initial implementation. * @param _admin_ Address of the administrator. * @param _data Data to send as msg.data to the implementation to initialize the proxied contract. * It should include the signature and the parameters of the function to be called, as described in * https://solidity.readthedocs.io/en/v0.4.24/abi-spec.html#function-selector-and-argument-encoding. * This parameter is optional, if no data is given the initialization call to proxied contract will be skipped. */ constructor( address _logic, address _admin_, bytes memory _data ) payable BaseFallback(_logic, _data) { assert(ADMIN_SLOT == bytes32(uint256(keccak256("eip1967.proxy.admin")) - 1)); _setAdmin(_admin_); } /** * @dev Emitted when the administration has been transferred. * @param previousAdmin Address of the previous admin. * @param newAdmin Address of the new admin. */ event AdminChanged(address previousAdmin, address newAdmin); /** * @dev Storage slot with the admin of the contract. * This is the keccak-256 hash of "eip1967.proxy.admin" subtracted by 1, and is * validated in the constructor. */ bytes32 internal constant ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103; /** * @dev Modifier to check whether the `msg.sender` is the admin. * If it is, it will run the function. Otherwise, it will delegate the call * to the implementation. */ modifier ifAdmin() { if (msg.sender == _admin()) { _; } else { _fallback(); } } /** * @return addr The address of the admin. */ function admin() external ifAdmin returns (address addr) { addr = _admin(); } /** * @return addr The address of the implementation. */ function implementation() external ifAdmin returns (address addr) { addr = _implementation(); } /** * @dev Changes the admin of the. * Only the current admin can call this function. * @param newAdmin Address to transfer administration to. */ function changeAdmin(address newAdmin) external ifAdmin { require(newAdmin != address(0), "Cannot change the admin of a proxy to the zero address"); emit AdminChanged(_admin(), newAdmin); _setAdmin(newAdmin); } /** * @dev Upgrade the backing implementation of the proxy. * Only the admin can call this function. * @param newImplementation Address of the new implementation. */ function upgradeTo(address newImplementation) external ifAdmin { _upgradeTo(newImplementation); } /** * @dev Upgrade the backing implementation of the proxy and call a function * on the new implementation. * This is useful to initialize the proxied contract. * @param newImplementation Address of the new implementation. * @param data Data to send as msg.data in the low level call. * It should include the signature and the parameters of the function to be called, as described in * https://solidity.readthedocs.io/en/v0.4.24/abi-spec.html#function-selector-and-argument-encoding. */ function upgradeToAndCall(address newImplementation, bytes calldata data) external payable ifAdmin { _upgradeTo(newImplementation); (bool success, ) = newImplementation.delegatecall(data); require(success); } /** * @return adm The admin slot. */ function _admin() internal view returns (address adm) { bytes32 slot = ADMIN_SLOT; assembly { adm := sload(slot) } } /** * @dev Sets the address of the proxy admin. * @param newAdmin Address of the new proxy admin. */ function _setAdmin(address newAdmin) internal { bytes32 slot = ADMIN_SLOT; assembly { sstore(slot, newAdmin) } } /** * @dev Only fall back when the sender is not the admin. */ function _willFallback() internal virtual override { require(msg.sender != _admin(), "Cannot call fallback function from the proxy admin"); super._willFallback(); } }
/** * @title VaultRouter * @dev This contract combines an upgradeability with an authorization * mechanism for administrative tasks. * All external functions in this contract must be guarded by the * `ifAdmin` modifier. See ethereum/solidity#3864 for a Solidity * feature proposal that would enable this to be done automatically. */
NatSpecMultiLine
_setAdmin
function _setAdmin(address newAdmin) internal { bytes32 slot = ADMIN_SLOT; assembly { sstore(slot, newAdmin) } }
/** * @dev Sets the address of the proxy admin. * @param newAdmin Address of the new proxy admin. */
NatSpecMultiLine
v0.8.4+commit.c7e474f2
MIT
ipfs://38ce5c6af5f119df33d6c128c761796ed6341eb5d78756f5cf54835a34958588
{ "func_code_index": [ 4053, 4217 ] }
419
VaultRouter
VaultRouter.sol
0x9e9f4b105e10a66b27c771811ce4defbd44567d2
Solidity
VaultRouter
contract VaultRouter is BaseFallback { /** * Contract constructor. * @param _logic address of the initial implementation. * @param _admin_ Address of the administrator. * @param _data Data to send as msg.data to the implementation to initialize the proxied contract. * It should include the signature and the parameters of the function to be called, as described in * https://solidity.readthedocs.io/en/v0.4.24/abi-spec.html#function-selector-and-argument-encoding. * This parameter is optional, if no data is given the initialization call to proxied contract will be skipped. */ constructor( address _logic, address _admin_, bytes memory _data ) payable BaseFallback(_logic, _data) { assert(ADMIN_SLOT == bytes32(uint256(keccak256("eip1967.proxy.admin")) - 1)); _setAdmin(_admin_); } /** * @dev Emitted when the administration has been transferred. * @param previousAdmin Address of the previous admin. * @param newAdmin Address of the new admin. */ event AdminChanged(address previousAdmin, address newAdmin); /** * @dev Storage slot with the admin of the contract. * This is the keccak-256 hash of "eip1967.proxy.admin" subtracted by 1, and is * validated in the constructor. */ bytes32 internal constant ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103; /** * @dev Modifier to check whether the `msg.sender` is the admin. * If it is, it will run the function. Otherwise, it will delegate the call * to the implementation. */ modifier ifAdmin() { if (msg.sender == _admin()) { _; } else { _fallback(); } } /** * @return addr The address of the admin. */ function admin() external ifAdmin returns (address addr) { addr = _admin(); } /** * @return addr The address of the implementation. */ function implementation() external ifAdmin returns (address addr) { addr = _implementation(); } /** * @dev Changes the admin of the. * Only the current admin can call this function. * @param newAdmin Address to transfer administration to. */ function changeAdmin(address newAdmin) external ifAdmin { require(newAdmin != address(0), "Cannot change the admin of a proxy to the zero address"); emit AdminChanged(_admin(), newAdmin); _setAdmin(newAdmin); } /** * @dev Upgrade the backing implementation of the proxy. * Only the admin can call this function. * @param newImplementation Address of the new implementation. */ function upgradeTo(address newImplementation) external ifAdmin { _upgradeTo(newImplementation); } /** * @dev Upgrade the backing implementation of the proxy and call a function * on the new implementation. * This is useful to initialize the proxied contract. * @param newImplementation Address of the new implementation. * @param data Data to send as msg.data in the low level call. * It should include the signature and the parameters of the function to be called, as described in * https://solidity.readthedocs.io/en/v0.4.24/abi-spec.html#function-selector-and-argument-encoding. */ function upgradeToAndCall(address newImplementation, bytes calldata data) external payable ifAdmin { _upgradeTo(newImplementation); (bool success, ) = newImplementation.delegatecall(data); require(success); } /** * @return adm The admin slot. */ function _admin() internal view returns (address adm) { bytes32 slot = ADMIN_SLOT; assembly { adm := sload(slot) } } /** * @dev Sets the address of the proxy admin. * @param newAdmin Address of the new proxy admin. */ function _setAdmin(address newAdmin) internal { bytes32 slot = ADMIN_SLOT; assembly { sstore(slot, newAdmin) } } /** * @dev Only fall back when the sender is not the admin. */ function _willFallback() internal virtual override { require(msg.sender != _admin(), "Cannot call fallback function from the proxy admin"); super._willFallback(); } }
/** * @title VaultRouter * @dev This contract combines an upgradeability with an authorization * mechanism for administrative tasks. * All external functions in this contract must be guarded by the * `ifAdmin` modifier. See ethereum/solidity#3864 for a Solidity * feature proposal that would enable this to be done automatically. */
NatSpecMultiLine
_willFallback
function _willFallback() internal virtual override { require(msg.sender != _admin(), "Cannot call fallback function from the proxy admin"); super._willFallback(); }
/** * @dev Only fall back when the sender is not the admin. */
NatSpecMultiLine
v0.8.4+commit.c7e474f2
MIT
ipfs://38ce5c6af5f119df33d6c128c761796ed6341eb5d78756f5cf54835a34958588
{ "func_code_index": [ 4300, 4492 ] }
420
Creature
contracts/Strings.sol
0xda396a2fc5f0e3a87a874757f1317102f49da5b0
Solidity
Strings
library Strings { // via https://github.com/oraclize/ethereum-api/blob/master/oraclizeAPI_0.5.sol function strConcat(string memory _a, string memory _b, string memory _c, string memory _d, string memory _e) internal pure returns (string memory) { bytes memory _ba = bytes(_a); bytes memory _bb = bytes(_b); bytes memory _bc = bytes(_c); bytes memory _bd = bytes(_d); bytes memory _be = bytes(_e); string memory abcde = new string(_ba.length + _bb.length + _bc.length + _bd.length + _be.length); bytes memory babcde = bytes(abcde); uint k = 0; for (uint i = 0; i < _ba.length; i++) babcde[k++] = _ba[i]; for (uint i = 0; i < _bb.length; i++) babcde[k++] = _bb[i]; for (uint i = 0; i < _bc.length; i++) babcde[k++] = _bc[i]; for (uint i = 0; i < _bd.length; i++) babcde[k++] = _bd[i]; for (uint i = 0; i < _be.length; i++) babcde[k++] = _be[i]; return string(babcde); } function strConcat(string memory _a, string memory _b, string memory _c, string memory _d) internal pure returns (string memory) { return strConcat(_a, _b, _c, _d, ""); } function strConcat(string memory _a, string memory _b, string memory _c) internal pure returns (string memory) { return strConcat(_a, _b, _c, "", ""); } function strConcat(string memory _a, string memory _b) internal pure returns (string memory) { return strConcat(_a, _b, "", "", ""); } function uint2str(uint _i) internal pure returns (string memory _uintAsString) { if (_i == 0) { return "0"; } uint j = _i; uint len; while (j != 0) { len++; j /= 10; } bytes memory bstr = new bytes(len); uint k = len - 1; while (_i != 0) { bstr[k--] = byte(uint8(48 + _i % 10)); _i /= 10; } return string(bstr); } function toString(address x) internal pure returns (string memory) { bytes memory b = new bytes(20); for (uint i = 0; i < 20; i++) b[i] = byte(uint8(uint(x) / (2**(8*(19 - i))))); return string(b); } }
strConcat
function strConcat(string memory _a, string memory _b, string memory _c, string memory _d, string memory _e) internal pure returns (string memory) { bytes memory _ba = bytes(_a); bytes memory _bb = bytes(_b); bytes memory _bc = bytes(_c); bytes memory _bd = bytes(_d); bytes memory _be = bytes(_e); string memory abcde = new string(_ba.length + _bb.length + _bc.length + _bd.length + _be.length); bytes memory babcde = bytes(abcde); uint k = 0; for (uint i = 0; i < _ba.length; i++) babcde[k++] = _ba[i]; for (uint i = 0; i < _bb.length; i++) babcde[k++] = _bb[i]; for (uint i = 0; i < _bc.length; i++) babcde[k++] = _bc[i]; for (uint i = 0; i < _bd.length; i++) babcde[k++] = _bd[i]; for (uint i = 0; i < _be.length; i++) babcde[k++] = _be[i]; return string(babcde); }
// via https://github.com/oraclize/ethereum-api/blob/master/oraclizeAPI_0.5.sol
LineComment
v0.5.12+commit.7709ece9
None
bzzr://f67c4a3b52bfc13e940ea61d0409c8ac3aedf1b9704cc9b99e361d7fc7a469e2
{ "func_code_index": [ 102, 977 ] }
421
PuppyToken
PuppyToken.sol
0xd326b9965f4ba85878d115f535167dd2305c8eb5
Solidity
IERC20
interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); }
totalSupply
function totalSupply() external view returns (uint256);
/** * @dev Returns the amount of tokens in existence. */
NatSpecMultiLine
v0.6.12+commit.27d51765
MIT
ipfs://ab18968b15b54a1237ca5750c8eaffc645d40798a62a5441626e6241ea7a2f8e
{ "func_code_index": [ 94, 154 ] }
422
PuppyToken
PuppyToken.sol
0xd326b9965f4ba85878d115f535167dd2305c8eb5
Solidity
IERC20
interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); }
balanceOf
function balanceOf(address account) external view returns (uint256);
/** * @dev Returns the amount of tokens owned by `account`. */
NatSpecMultiLine
v0.6.12+commit.27d51765
MIT
ipfs://ab18968b15b54a1237ca5750c8eaffc645d40798a62a5441626e6241ea7a2f8e
{ "func_code_index": [ 237, 310 ] }
423
PuppyToken
PuppyToken.sol
0xd326b9965f4ba85878d115f535167dd2305c8eb5
Solidity
IERC20
interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); }
transfer
function transfer(address recipient, uint256 amount) external returns (bool);
/** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */
NatSpecMultiLine
v0.6.12+commit.27d51765
MIT
ipfs://ab18968b15b54a1237ca5750c8eaffc645d40798a62a5441626e6241ea7a2f8e
{ "func_code_index": [ 534, 616 ] }
424
PuppyToken
PuppyToken.sol
0xd326b9965f4ba85878d115f535167dd2305c8eb5
Solidity
IERC20
interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); }
allowance
function allowance(address owner, address spender) external view returns (uint256);
/** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */
NatSpecMultiLine
v0.6.12+commit.27d51765
MIT
ipfs://ab18968b15b54a1237ca5750c8eaffc645d40798a62a5441626e6241ea7a2f8e
{ "func_code_index": [ 895, 983 ] }
425
PuppyToken
PuppyToken.sol
0xd326b9965f4ba85878d115f535167dd2305c8eb5
Solidity
IERC20
interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); }
approve
function approve(address spender, uint256 amount) external returns (bool);
/** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */
NatSpecMultiLine
v0.6.12+commit.27d51765
MIT
ipfs://ab18968b15b54a1237ca5750c8eaffc645d40798a62a5441626e6241ea7a2f8e
{ "func_code_index": [ 1647, 1726 ] }
426
PuppyToken
PuppyToken.sol
0xd326b9965f4ba85878d115f535167dd2305c8eb5
Solidity
IERC20
interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); }
transferFrom
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
/** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */
NatSpecMultiLine
v0.6.12+commit.27d51765
MIT
ipfs://ab18968b15b54a1237ca5750c8eaffc645d40798a62a5441626e6241ea7a2f8e
{ "func_code_index": [ 2039, 2141 ] }
427
PuppyToken
PuppyToken.sol
0xd326b9965f4ba85878d115f535167dd2305c8eb5
Solidity
SafeMath
library SafeMath { /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers. Reverts on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); } /** * @dev Returns the integer division of two unsigned integers. Reverts with custom message on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { return mod(a, b, "SafeMath: modulo by zero"); } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts with custom message when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } }
add
function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; }
/** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * * - Addition cannot overflow. */
NatSpecMultiLine
v0.6.12+commit.27d51765
MIT
ipfs://ab18968b15b54a1237ca5750c8eaffc645d40798a62a5441626e6241ea7a2f8e
{ "func_code_index": [ 259, 445 ] }
428
PuppyToken
PuppyToken.sol
0xd326b9965f4ba85878d115f535167dd2305c8eb5
Solidity
SafeMath
library SafeMath { /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers. Reverts on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); } /** * @dev Returns the integer division of two unsigned integers. Reverts with custom message on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { return mod(a, b, "SafeMath: modulo by zero"); } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts with custom message when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } }
sub
function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); }
/** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */
NatSpecMultiLine
v0.6.12+commit.27d51765
MIT
ipfs://ab18968b15b54a1237ca5750c8eaffc645d40798a62a5441626e6241ea7a2f8e
{ "func_code_index": [ 723, 864 ] }
429
PuppyToken
PuppyToken.sol
0xd326b9965f4ba85878d115f535167dd2305c8eb5
Solidity
SafeMath
library SafeMath { /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers. Reverts on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); } /** * @dev Returns the integer division of two unsigned integers. Reverts with custom message on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { return mod(a, b, "SafeMath: modulo by zero"); } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts with custom message when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } }
sub
function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; }
/** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */
NatSpecMultiLine
v0.6.12+commit.27d51765
MIT
ipfs://ab18968b15b54a1237ca5750c8eaffc645d40798a62a5441626e6241ea7a2f8e
{ "func_code_index": [ 1162, 1359 ] }
430
PuppyToken
PuppyToken.sol
0xd326b9965f4ba85878d115f535167dd2305c8eb5
Solidity
SafeMath
library SafeMath { /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers. Reverts on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); } /** * @dev Returns the integer division of two unsigned integers. Reverts with custom message on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { return mod(a, b, "SafeMath: modulo by zero"); } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts with custom message when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } }
mul
function mul(uint256 a, uint256 b) internal pure returns (uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; }
/** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * * - Multiplication cannot overflow. */
NatSpecMultiLine
v0.6.12+commit.27d51765
MIT
ipfs://ab18968b15b54a1237ca5750c8eaffc645d40798a62a5441626e6241ea7a2f8e
{ "func_code_index": [ 1613, 2089 ] }
431
PuppyToken
PuppyToken.sol
0xd326b9965f4ba85878d115f535167dd2305c8eb5
Solidity
SafeMath
library SafeMath { /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers. Reverts on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); } /** * @dev Returns the integer division of two unsigned integers. Reverts with custom message on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { return mod(a, b, "SafeMath: modulo by zero"); } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts with custom message when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } }
div
function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); }
/** * @dev Returns the integer division of two unsigned integers. Reverts on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */
NatSpecMultiLine
v0.6.12+commit.27d51765
MIT
ipfs://ab18968b15b54a1237ca5750c8eaffc645d40798a62a5441626e6241ea7a2f8e
{ "func_code_index": [ 2560, 2697 ] }
432
PuppyToken
PuppyToken.sol
0xd326b9965f4ba85878d115f535167dd2305c8eb5
Solidity
SafeMath
library SafeMath { /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers. Reverts on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); } /** * @dev Returns the integer division of two unsigned integers. Reverts with custom message on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { return mod(a, b, "SafeMath: modulo by zero"); } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts with custom message when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } }
div
function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; }
/** * @dev Returns the integer division of two unsigned integers. Reverts with custom message on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */
NatSpecMultiLine
v0.6.12+commit.27d51765
MIT
ipfs://ab18968b15b54a1237ca5750c8eaffc645d40798a62a5441626e6241ea7a2f8e
{ "func_code_index": [ 3188, 3471 ] }
433
PuppyToken
PuppyToken.sol
0xd326b9965f4ba85878d115f535167dd2305c8eb5
Solidity
SafeMath
library SafeMath { /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers. Reverts on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); } /** * @dev Returns the integer division of two unsigned integers. Reverts with custom message on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { return mod(a, b, "SafeMath: modulo by zero"); } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts with custom message when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } }
mod
function mod(uint256 a, uint256 b) internal pure returns (uint256) { return mod(a, b, "SafeMath: modulo by zero"); }
/** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */
NatSpecMultiLine
v0.6.12+commit.27d51765
MIT
ipfs://ab18968b15b54a1237ca5750c8eaffc645d40798a62a5441626e6241ea7a2f8e
{ "func_code_index": [ 3931, 4066 ] }
434
PuppyToken
PuppyToken.sol
0xd326b9965f4ba85878d115f535167dd2305c8eb5
Solidity
SafeMath
library SafeMath { /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers. Reverts on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); } /** * @dev Returns the integer division of two unsigned integers. Reverts with custom message on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { return mod(a, b, "SafeMath: modulo by zero"); } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts with custom message when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } }
mod
function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; }
/** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts with custom message when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */
NatSpecMultiLine
v0.6.12+commit.27d51765
MIT
ipfs://ab18968b15b54a1237ca5750c8eaffc645d40798a62a5441626e6241ea7a2f8e
{ "func_code_index": [ 4546, 4717 ] }
435
PuppyToken
PuppyToken.sol
0xd326b9965f4ba85878d115f535167dd2305c8eb5
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); } } } }
isContract
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 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 * ==== */
NatSpecMultiLine
v0.6.12+commit.27d51765
MIT
ipfs://ab18968b15b54a1237ca5750c8eaffc645d40798a62a5441626e6241ea7a2f8e
{ "func_code_index": [ 606, 1230 ] }
436
PuppyToken
PuppyToken.sol
0xd326b9965f4ba85878d115f535167dd2305c8eb5
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://ab18968b15b54a1237ca5750c8eaffc645d40798a62a5441626e6241ea7a2f8e
{ "func_code_index": [ 2160, 2562 ] }
437
PuppyToken
PuppyToken.sol
0xd326b9965f4ba85878d115f535167dd2305c8eb5
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://ab18968b15b54a1237ca5750c8eaffc645d40798a62a5441626e6241ea7a2f8e
{ "func_code_index": [ 3318, 3496 ] }
438
PuppyToken
PuppyToken.sol
0xd326b9965f4ba85878d115f535167dd2305c8eb5
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://ab18968b15b54a1237ca5750c8eaffc645d40798a62a5441626e6241ea7a2f8e
{ "func_code_index": [ 3721, 3922 ] }
439
PuppyToken
PuppyToken.sol
0xd326b9965f4ba85878d115f535167dd2305c8eb5
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://ab18968b15b54a1237ca5750c8eaffc645d40798a62a5441626e6241ea7a2f8e
{ "func_code_index": [ 4292, 4523 ] }
440
PuppyToken
PuppyToken.sol
0xd326b9965f4ba85878d115f535167dd2305c8eb5
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://ab18968b15b54a1237ca5750c8eaffc645d40798a62a5441626e6241ea7a2f8e
{ "func_code_index": [ 4774, 5095 ] }
441
PuppyToken
PuppyToken.sol
0xd326b9965f4ba85878d115f535167dd2305c8eb5
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://ab18968b15b54a1237ca5750c8eaffc645d40798a62a5441626e6241ea7a2f8e
{ "func_code_index": [ 497, 581 ] }
442
PuppyToken
PuppyToken.sol
0xd326b9965f4ba85878d115f535167dd2305c8eb5
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://ab18968b15b54a1237ca5750c8eaffc645d40798a62a5441626e6241ea7a2f8e
{ "func_code_index": [ 1139, 1292 ] }
443
PuppyToken
PuppyToken.sol
0xd326b9965f4ba85878d115f535167dd2305c8eb5
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://ab18968b15b54a1237ca5750c8eaffc645d40798a62a5441626e6241ea7a2f8e
{ "func_code_index": [ 1442, 1691 ] }
444
idoFactory
tokenVesting.sol
0xb9f4fcc06b48cd072aa3dd62b9287f28eb35c13b
Solidity
PostDeliveryCrowdsale
contract PostDeliveryCrowdsale is TimedCrowdsale { using SafeMath for uint256; uint contractCreationTime; uint monthTime = 2592000; uint public timeToWait; uint public initialEmission; uint public months; uint public lastFunctioncalled; mapping(address => uint256) private _balances; mapping(address => uint256) private _totalClaimed; __unstable__TokenVault private _vault; constructor(uint _initialEmission, uint _timeToWait, uint _months) public { require(_timeToWait>0, "TimeToWait is 0"); uint closingTime = closingTime(); contractCreationTime = closingTime; initialEmission = _initialEmission; timeToWait = _timeToWait ; months = _months; _vault = new __unstable__TokenVault(); } function currentRetractableTokens(address beneficiary) view public returns(uint){ require(hasClosed(), "PostDeliveryCrowdsale: not closed"); uint256 amount = _balances[beneficiary]; uint realAmount; if(amount<=0){ return 0; } uint since = block.timestamp - contractCreationTime; if(initialEmission==100){ return amount; } else if((since/monthTime)< timeToWait){ realAmount = ((initialEmission*(amount+_totalClaimed[beneficiary]))/100) - _totalClaimed[beneficiary]; return realAmount; } else { uint restEmission = 100 - initialEmission; realAmount = ((initialEmission*(amount+_totalClaimed[beneficiary]))/100) + (restEmission*(amount + _totalClaimed[beneficiary])*((since/monthTime) + 1 - timeToWait)/months/100) - _totalClaimed[beneficiary]; if(realAmount==0){ return 0; } if(realAmount>_balances[beneficiary]){ realAmount = _balances[beneficiary]; } return realAmount; } } /** * @dev Withdraw tokens only after crowdsale ends. * @param beneficiary Whose tokens will be withdrawn. */ function withdrawTokens(address beneficiary) public { require(hasClosed(), "PostDeliveryCrowdsale: not closed"); uint256 amount = _balances[beneficiary]; uint realAmount; require(amount > 0, "PostDeliveryCrowdsale: beneficiary is not due any tokens"); uint since = block.timestamp - contractCreationTime; if(initialEmission==100){ _balances[beneficiary] = 0; _vault.transfer(token(), beneficiary, amount); _totalClaimed[beneficiary] += amount; lastFunctioncalled = 1; } else if((since/monthTime)< timeToWait){ realAmount = ((initialEmission*amount)/100) - _totalClaimed[beneficiary]; require(realAmount>0,"Current Retractable Amount 0"); _balances[beneficiary] -= realAmount ; _vault.transfer(token(), beneficiary, realAmount); _totalClaimed[beneficiary] += realAmount; lastFunctioncalled =2; } else { uint restEmission = 100 - initialEmission; realAmount = ((initialEmission*(amount+_totalClaimed[beneficiary]))/100) + (restEmission*(amount + _totalClaimed[beneficiary])*((since/monthTime) + 1 - timeToWait)/months/100) - _totalClaimed[beneficiary]; require(realAmount>0,"Current Retractable Amount 0"); if(realAmount>_balances[beneficiary]){ _totalClaimed[beneficiary] += _balances[beneficiary]; realAmount = _balances[beneficiary]; lastFunctioncalled = 3; } _balances[beneficiary] -= realAmount ; _vault.transfer(token(), beneficiary, realAmount); _totalClaimed[beneficiary] += realAmount; lastFunctioncalled = 4; } } /** * @return the balance of an account. */ function balanceOf(address account) public view returns (uint256) { return _balances[account]; } /** * @dev Overrides parent by storing due balances, and delivering tokens to the vault instead of the end user. This * ensures that the tokens will be available by the time they are withdrawn (which may not be the case if * `_deliverTokens` was called later). * @param beneficiary Token purchaser * @param tokenAmount Amount of tokens purchased */ function _processPurchase(address beneficiary, uint256 tokenAmount) internal { _balances[beneficiary] = _balances[beneficiary].add(tokenAmount); _deliverTokens(address(_vault), tokenAmount); } }
/** * @title PostDeliveryCrowdsale * @dev Crowdsale that locks tokens from withdrawal until it ends. */
NatSpecMultiLine
withdrawTokens
function withdrawTokens(address beneficiary) public { require(hasClosed(), "PostDeliveryCrowdsale: not closed"); uint256 amount = _balances[beneficiary]; uint realAmount; require(amount > 0, "PostDeliveryCrowdsale: beneficiary is not due any tokens"); uint since = block.timestamp - contractCreationTime; if(initialEmission==100){ _balances[beneficiary] = 0; _vault.transfer(token(), beneficiary, amount); _totalClaimed[beneficiary] += amount; lastFunctioncalled = 1; } else if((since/monthTime)< timeToWait){ realAmount = ((initialEmission*amount)/100) - _totalClaimed[beneficiary]; require(realAmount>0,"Current Retractable Amount 0"); _balances[beneficiary] -= realAmount ; _vault.transfer(token(), beneficiary, realAmount); _totalClaimed[beneficiary] += realAmount; lastFunctioncalled =2; } else { uint restEmission = 100 - initialEmission; realAmount = ((initialEmission*(amount+_totalClaimed[beneficiary]))/100) + (restEmission*(amount + _totalClaimed[beneficiary])*((since/monthTime) + 1 - timeToWait)/months/100) - _totalClaimed[beneficiary]; require(realAmount>0,"Current Retractable Amount 0"); if(realAmount>_balances[beneficiary]){ _totalClaimed[beneficiary] += _balances[beneficiary]; realAmount = _balances[beneficiary]; lastFunctioncalled = 3; } _balances[beneficiary] -= realAmount ; _vault.transfer(token(), beneficiary, realAmount); _totalClaimed[beneficiary] += realAmount; lastFunctioncalled = 4; } }
/** * @dev Withdraw tokens only after crowdsale ends. * @param beneficiary Whose tokens will be withdrawn. */
NatSpecMultiLine
v0.5.17+commit.d19bba13
GNU GPLv3
bzzr://710c3fd9dd1e5dbde5ea7c504730f3a39f4e4d99d3d5f7d78df96d15723a33ee
{ "func_code_index": [ 2165, 4036 ] }
445
idoFactory
tokenVesting.sol
0xb9f4fcc06b48cd072aa3dd62b9287f28eb35c13b
Solidity
PostDeliveryCrowdsale
contract PostDeliveryCrowdsale is TimedCrowdsale { using SafeMath for uint256; uint contractCreationTime; uint monthTime = 2592000; uint public timeToWait; uint public initialEmission; uint public months; uint public lastFunctioncalled; mapping(address => uint256) private _balances; mapping(address => uint256) private _totalClaimed; __unstable__TokenVault private _vault; constructor(uint _initialEmission, uint _timeToWait, uint _months) public { require(_timeToWait>0, "TimeToWait is 0"); uint closingTime = closingTime(); contractCreationTime = closingTime; initialEmission = _initialEmission; timeToWait = _timeToWait ; months = _months; _vault = new __unstable__TokenVault(); } function currentRetractableTokens(address beneficiary) view public returns(uint){ require(hasClosed(), "PostDeliveryCrowdsale: not closed"); uint256 amount = _balances[beneficiary]; uint realAmount; if(amount<=0){ return 0; } uint since = block.timestamp - contractCreationTime; if(initialEmission==100){ return amount; } else if((since/monthTime)< timeToWait){ realAmount = ((initialEmission*(amount+_totalClaimed[beneficiary]))/100) - _totalClaimed[beneficiary]; return realAmount; } else { uint restEmission = 100 - initialEmission; realAmount = ((initialEmission*(amount+_totalClaimed[beneficiary]))/100) + (restEmission*(amount + _totalClaimed[beneficiary])*((since/monthTime) + 1 - timeToWait)/months/100) - _totalClaimed[beneficiary]; if(realAmount==0){ return 0; } if(realAmount>_balances[beneficiary]){ realAmount = _balances[beneficiary]; } return realAmount; } } /** * @dev Withdraw tokens only after crowdsale ends. * @param beneficiary Whose tokens will be withdrawn. */ function withdrawTokens(address beneficiary) public { require(hasClosed(), "PostDeliveryCrowdsale: not closed"); uint256 amount = _balances[beneficiary]; uint realAmount; require(amount > 0, "PostDeliveryCrowdsale: beneficiary is not due any tokens"); uint since = block.timestamp - contractCreationTime; if(initialEmission==100){ _balances[beneficiary] = 0; _vault.transfer(token(), beneficiary, amount); _totalClaimed[beneficiary] += amount; lastFunctioncalled = 1; } else if((since/monthTime)< timeToWait){ realAmount = ((initialEmission*amount)/100) - _totalClaimed[beneficiary]; require(realAmount>0,"Current Retractable Amount 0"); _balances[beneficiary] -= realAmount ; _vault.transfer(token(), beneficiary, realAmount); _totalClaimed[beneficiary] += realAmount; lastFunctioncalled =2; } else { uint restEmission = 100 - initialEmission; realAmount = ((initialEmission*(amount+_totalClaimed[beneficiary]))/100) + (restEmission*(amount + _totalClaimed[beneficiary])*((since/monthTime) + 1 - timeToWait)/months/100) - _totalClaimed[beneficiary]; require(realAmount>0,"Current Retractable Amount 0"); if(realAmount>_balances[beneficiary]){ _totalClaimed[beneficiary] += _balances[beneficiary]; realAmount = _balances[beneficiary]; lastFunctioncalled = 3; } _balances[beneficiary] -= realAmount ; _vault.transfer(token(), beneficiary, realAmount); _totalClaimed[beneficiary] += realAmount; lastFunctioncalled = 4; } } /** * @return the balance of an account. */ function balanceOf(address account) public view returns (uint256) { return _balances[account]; } /** * @dev Overrides parent by storing due balances, and delivering tokens to the vault instead of the end user. This * ensures that the tokens will be available by the time they are withdrawn (which may not be the case if * `_deliverTokens` was called later). * @param beneficiary Token purchaser * @param tokenAmount Amount of tokens purchased */ function _processPurchase(address beneficiary, uint256 tokenAmount) internal { _balances[beneficiary] = _balances[beneficiary].add(tokenAmount); _deliverTokens(address(_vault), tokenAmount); } }
/** * @title PostDeliveryCrowdsale * @dev Crowdsale that locks tokens from withdrawal until it ends. */
NatSpecMultiLine
balanceOf
function balanceOf(address account) public view returns (uint256) { return _balances[account]; }
/** * @return the balance of an account. */
NatSpecMultiLine
v0.5.17+commit.d19bba13
GNU GPLv3
bzzr://710c3fd9dd1e5dbde5ea7c504730f3a39f4e4d99d3d5f7d78df96d15723a33ee
{ "func_code_index": [ 4100, 4215 ] }
446
idoFactory
tokenVesting.sol
0xb9f4fcc06b48cd072aa3dd62b9287f28eb35c13b
Solidity
PostDeliveryCrowdsale
contract PostDeliveryCrowdsale is TimedCrowdsale { using SafeMath for uint256; uint contractCreationTime; uint monthTime = 2592000; uint public timeToWait; uint public initialEmission; uint public months; uint public lastFunctioncalled; mapping(address => uint256) private _balances; mapping(address => uint256) private _totalClaimed; __unstable__TokenVault private _vault; constructor(uint _initialEmission, uint _timeToWait, uint _months) public { require(_timeToWait>0, "TimeToWait is 0"); uint closingTime = closingTime(); contractCreationTime = closingTime; initialEmission = _initialEmission; timeToWait = _timeToWait ; months = _months; _vault = new __unstable__TokenVault(); } function currentRetractableTokens(address beneficiary) view public returns(uint){ require(hasClosed(), "PostDeliveryCrowdsale: not closed"); uint256 amount = _balances[beneficiary]; uint realAmount; if(amount<=0){ return 0; } uint since = block.timestamp - contractCreationTime; if(initialEmission==100){ return amount; } else if((since/monthTime)< timeToWait){ realAmount = ((initialEmission*(amount+_totalClaimed[beneficiary]))/100) - _totalClaimed[beneficiary]; return realAmount; } else { uint restEmission = 100 - initialEmission; realAmount = ((initialEmission*(amount+_totalClaimed[beneficiary]))/100) + (restEmission*(amount + _totalClaimed[beneficiary])*((since/monthTime) + 1 - timeToWait)/months/100) - _totalClaimed[beneficiary]; if(realAmount==0){ return 0; } if(realAmount>_balances[beneficiary]){ realAmount = _balances[beneficiary]; } return realAmount; } } /** * @dev Withdraw tokens only after crowdsale ends. * @param beneficiary Whose tokens will be withdrawn. */ function withdrawTokens(address beneficiary) public { require(hasClosed(), "PostDeliveryCrowdsale: not closed"); uint256 amount = _balances[beneficiary]; uint realAmount; require(amount > 0, "PostDeliveryCrowdsale: beneficiary is not due any tokens"); uint since = block.timestamp - contractCreationTime; if(initialEmission==100){ _balances[beneficiary] = 0; _vault.transfer(token(), beneficiary, amount); _totalClaimed[beneficiary] += amount; lastFunctioncalled = 1; } else if((since/monthTime)< timeToWait){ realAmount = ((initialEmission*amount)/100) - _totalClaimed[beneficiary]; require(realAmount>0,"Current Retractable Amount 0"); _balances[beneficiary] -= realAmount ; _vault.transfer(token(), beneficiary, realAmount); _totalClaimed[beneficiary] += realAmount; lastFunctioncalled =2; } else { uint restEmission = 100 - initialEmission; realAmount = ((initialEmission*(amount+_totalClaimed[beneficiary]))/100) + (restEmission*(amount + _totalClaimed[beneficiary])*((since/monthTime) + 1 - timeToWait)/months/100) - _totalClaimed[beneficiary]; require(realAmount>0,"Current Retractable Amount 0"); if(realAmount>_balances[beneficiary]){ _totalClaimed[beneficiary] += _balances[beneficiary]; realAmount = _balances[beneficiary]; lastFunctioncalled = 3; } _balances[beneficiary] -= realAmount ; _vault.transfer(token(), beneficiary, realAmount); _totalClaimed[beneficiary] += realAmount; lastFunctioncalled = 4; } } /** * @return the balance of an account. */ function balanceOf(address account) public view returns (uint256) { return _balances[account]; } /** * @dev Overrides parent by storing due balances, and delivering tokens to the vault instead of the end user. This * ensures that the tokens will be available by the time they are withdrawn (which may not be the case if * `_deliverTokens` was called later). * @param beneficiary Token purchaser * @param tokenAmount Amount of tokens purchased */ function _processPurchase(address beneficiary, uint256 tokenAmount) internal { _balances[beneficiary] = _balances[beneficiary].add(tokenAmount); _deliverTokens(address(_vault), tokenAmount); } }
/** * @title PostDeliveryCrowdsale * @dev Crowdsale that locks tokens from withdrawal until it ends. */
NatSpecMultiLine
_processPurchase
function _processPurchase(address beneficiary, uint256 tokenAmount) internal { _balances[beneficiary] = _balances[beneficiary].add(tokenAmount); _deliverTokens(address(_vault), tokenAmount); }
/** * @dev Overrides parent by storing due balances, and delivering tokens to the vault instead of the end user. This * ensures that the tokens will be available by the time they are withdrawn (which may not be the case if * `_deliverTokens` was called later). * @param beneficiary Token purchaser * @param tokenAmount Amount of tokens purchased */
NatSpecMultiLine
v0.5.17+commit.d19bba13
GNU GPLv3
bzzr://710c3fd9dd1e5dbde5ea7c504730f3a39f4e4d99d3d5f7d78df96d15723a33ee
{ "func_code_index": [ 4608, 4828 ] }
447
Token
Token.sol
0xa35defddc628619ffc0ec4e6cb53990e2e07af18
Solidity
SafeMath
library SafeMath { /** * @dev Multiplies two numbers, reverts on overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "multiplication constraint voilated"); return c; } /** * @dev Integer division of two numbers truncating the quotient, reverts on division by zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { // Solidity only automatically asserts when dividing by 0 require(b > 0, "division constraint voilated"); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Subtracts two numbers, reverts on overflow (i.e. if subtrahend is greater than minuend). */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { require(b <= a, "substracts constraint voilated"); uint256 c = a - b; return c; } /** * @dev Adds two numbers, reverts on overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "addition constraint voilated"); return c; } /** * @dev Divides two numbers and returns the remainder (unsigned integer modulo), * reverts when dividing by zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { require(b != 0, "divides contraint voilated"); return a % b; } }
/** * @title SafeMath * @dev Math operations with safety checks that revert on error */
NatSpecMultiLine
mul
function mul(uint256 a, uint256 b) internal pure returns (uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "multiplication constraint voilated"); return c; }
/** * @dev Multiplies two numbers, reverts on overflow. */
NatSpecMultiLine
v0.5.2+commit.1df8f40c
None
bzzr://306b2738991d3879748fe11086a1d55010dc0fdbdb38181b082853584c31a3c8
{ "func_code_index": [ 94, 486 ] }
448
Token
Token.sol
0xa35defddc628619ffc0ec4e6cb53990e2e07af18
Solidity
SafeMath
library SafeMath { /** * @dev Multiplies two numbers, reverts on overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "multiplication constraint voilated"); return c; } /** * @dev Integer division of two numbers truncating the quotient, reverts on division by zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { // Solidity only automatically asserts when dividing by 0 require(b > 0, "division constraint voilated"); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Subtracts two numbers, reverts on overflow (i.e. if subtrahend is greater than minuend). */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { require(b <= a, "substracts constraint voilated"); uint256 c = a - b; return c; } /** * @dev Adds two numbers, reverts on overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "addition constraint voilated"); return c; } /** * @dev Divides two numbers and returns the remainder (unsigned integer modulo), * reverts when dividing by zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { require(b != 0, "divides contraint voilated"); return a % b; } }
/** * @title SafeMath * @dev Math operations with safety checks that revert on error */
NatSpecMultiLine
div
function div(uint256 a, uint256 b) internal pure returns (uint256) { // Solidity only automatically asserts when dividing by 0 require(b > 0, "division constraint voilated"); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; }
/** * @dev Integer division of two numbers truncating the quotient, reverts on division by zero. */
NatSpecMultiLine
v0.5.2+commit.1df8f40c
None
bzzr://306b2738991d3879748fe11086a1d55010dc0fdbdb38181b082853584c31a3c8
{ "func_code_index": [ 604, 942 ] }
449
Token
Token.sol
0xa35defddc628619ffc0ec4e6cb53990e2e07af18
Solidity
SafeMath
library SafeMath { /** * @dev Multiplies two numbers, reverts on overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "multiplication constraint voilated"); return c; } /** * @dev Integer division of two numbers truncating the quotient, reverts on division by zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { // Solidity only automatically asserts when dividing by 0 require(b > 0, "division constraint voilated"); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Subtracts two numbers, reverts on overflow (i.e. if subtrahend is greater than minuend). */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { require(b <= a, "substracts constraint voilated"); uint256 c = a - b; return c; } /** * @dev Adds two numbers, reverts on overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "addition constraint voilated"); return c; } /** * @dev Divides two numbers and returns the remainder (unsigned integer modulo), * reverts when dividing by zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { require(b != 0, "divides contraint voilated"); return a % b; } }
/** * @title SafeMath * @dev Math operations with safety checks that revert on error */
NatSpecMultiLine
sub
function sub(uint256 a, uint256 b) internal pure returns (uint256) { require(b <= a, "substracts constraint voilated"); uint256 c = a - b; return c; }
/** * @dev Subtracts two numbers, reverts on overflow (i.e. if subtrahend is greater than minuend). */
NatSpecMultiLine
v0.5.2+commit.1df8f40c
None
bzzr://306b2738991d3879748fe11086a1d55010dc0fdbdb38181b082853584c31a3c8
{ "func_code_index": [ 1063, 1250 ] }
450
Token
Token.sol
0xa35defddc628619ffc0ec4e6cb53990e2e07af18
Solidity
SafeMath
library SafeMath { /** * @dev Multiplies two numbers, reverts on overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "multiplication constraint voilated"); return c; } /** * @dev Integer division of two numbers truncating the quotient, reverts on division by zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { // Solidity only automatically asserts when dividing by 0 require(b > 0, "division constraint voilated"); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Subtracts two numbers, reverts on overflow (i.e. if subtrahend is greater than minuend). */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { require(b <= a, "substracts constraint voilated"); uint256 c = a - b; return c; } /** * @dev Adds two numbers, reverts on overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "addition constraint voilated"); return c; } /** * @dev Divides two numbers and returns the remainder (unsigned integer modulo), * reverts when dividing by zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { require(b != 0, "divides contraint voilated"); return a % b; } }
/** * @title SafeMath * @dev Math operations with safety checks that revert on error */
NatSpecMultiLine
add
function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "addition constraint voilated"); return c; }
/** * @dev Adds two numbers, reverts on overflow. */
NatSpecMultiLine
v0.5.2+commit.1df8f40c
None
bzzr://306b2738991d3879748fe11086a1d55010dc0fdbdb38181b082853584c31a3c8
{ "func_code_index": [ 1321, 1506 ] }
451
Token
Token.sol
0xa35defddc628619ffc0ec4e6cb53990e2e07af18
Solidity
SafeMath
library SafeMath { /** * @dev Multiplies two numbers, reverts on overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "multiplication constraint voilated"); return c; } /** * @dev Integer division of two numbers truncating the quotient, reverts on division by zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { // Solidity only automatically asserts when dividing by 0 require(b > 0, "division constraint voilated"); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Subtracts two numbers, reverts on overflow (i.e. if subtrahend is greater than minuend). */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { require(b <= a, "substracts constraint voilated"); uint256 c = a - b; return c; } /** * @dev Adds two numbers, reverts on overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "addition constraint voilated"); return c; } /** * @dev Divides two numbers and returns the remainder (unsigned integer modulo), * reverts when dividing by zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { require(b != 0, "divides contraint voilated"); return a % b; } }
/** * @title SafeMath * @dev Math operations with safety checks that revert on error */
NatSpecMultiLine
mod
function mod(uint256 a, uint256 b) internal pure returns (uint256) { require(b != 0, "divides contraint voilated"); return a % b; }
/** * @dev Divides two numbers and returns the remainder (unsigned integer modulo), * reverts when dividing by zero. */
NatSpecMultiLine
v0.5.2+commit.1df8f40c
None
bzzr://306b2738991d3879748fe11086a1d55010dc0fdbdb38181b082853584c31a3c8
{ "func_code_index": [ 1649, 1808 ] }
452
Token
Token.sol
0xa35defddc628619ffc0ec4e6cb53990e2e07af18
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, "Ownable: only owner can execute"); _; } /** * @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), "Ownable: new owner should not empty"); 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), "Ownable: new owner should not empty"); 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.5.2+commit.1df8f40c
None
bzzr://306b2738991d3879748fe11086a1d55010dc0fdbdb38181b082853584c31a3c8
{ "func_code_index": [ 657, 877 ] }
453
Token
Token.sol
0xa35defddc628619ffc0ec4e6cb53990e2e07af18
Solidity
Pausable
contract Pausable is Ownable { event Pause(); event Unpause(); bool public paused = false; /** * @dev modifier to allow actions only when the contract IS paused */ modifier whenNotPaused() { require(!paused, "Pausable: contract not paused"); _; } /** * @dev modifier to allow actions only when the contract IS NOT paused */ modifier whenPaused { require(paused, "Pausable: contract paused"); _; } /** * @dev called by the owner to pause, triggers stopped state */ function pause() public onlyOwner whenNotPaused returns (bool) { paused = true; emit Pause(); return true; } /** * @dev called by the owner to unpause, returns to normal state */ function unpause() public onlyOwner whenPaused returns (bool) { paused = false; emit Unpause(); return true; } }
pause
function pause() public onlyOwner whenNotPaused returns (bool) { paused = true; emit Pause(); return true; }
/** * @dev called by the owner to pause, triggers stopped state */
NatSpecMultiLine
v0.5.2+commit.1df8f40c
None
bzzr://306b2738991d3879748fe11086a1d55010dc0fdbdb38181b082853584c31a3c8
{ "func_code_index": [ 543, 672 ] }
454
Token
Token.sol
0xa35defddc628619ffc0ec4e6cb53990e2e07af18
Solidity
Pausable
contract Pausable is Ownable { event Pause(); event Unpause(); bool public paused = false; /** * @dev modifier to allow actions only when the contract IS paused */ modifier whenNotPaused() { require(!paused, "Pausable: contract not paused"); _; } /** * @dev modifier to allow actions only when the contract IS NOT paused */ modifier whenPaused { require(paused, "Pausable: contract paused"); _; } /** * @dev called by the owner to pause, triggers stopped state */ function pause() public onlyOwner whenNotPaused returns (bool) { paused = true; emit Pause(); return true; } /** * @dev called by the owner to unpause, returns to normal state */ function unpause() public onlyOwner whenPaused returns (bool) { paused = false; emit Unpause(); return true; } }
unpause
function unpause() public onlyOwner whenPaused returns (bool) { paused = false; emit Unpause(); return true; }
/** * @dev called by the owner to unpause, returns to normal state */
NatSpecMultiLine
v0.5.2+commit.1df8f40c
None
bzzr://306b2738991d3879748fe11086a1d55010dc0fdbdb38181b082853584c31a3c8
{ "func_code_index": [ 756, 887 ] }
455
Token
Token.sol
0xa35defddc628619ffc0ec4e6cb53990e2e07af18
Solidity
BasicToken
contract BasicToken is ERC20Basic { using SafeMath for uint256; mapping(address => uint256) balances; /** * @dev transfer token for a specified address * @param _to The address to transfer to. * @param _value The amount to be transferred. */ function transfer(address _to, uint256 _value) public returns (bool) { require(_to != address(0), "BasicToken: require to address"); // SafeMath.sub will throw if there is not enough balance. 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 _owner The address to query the the balance of. * @return An uint256 representing the amount owned by the passed address. */ function balanceOf(address _owner) public view returns (uint256 balance) { return balances[_owner]; } }
/** * @title Basic token * @dev Basic version of StandardToken, with no allowances. */
NatSpecMultiLine
transfer
function transfer(address _to, uint256 _value) public returns (bool) { require(_to != address(0), "BasicToken: require to address"); // SafeMath.sub will throw if there is not enough balance. 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.5.2+commit.1df8f40c
None
bzzr://306b2738991d3879748fe11086a1d55010dc0fdbdb38181b082853584c31a3c8
{ "func_code_index": [ 264, 646 ] }
456
Token
Token.sol
0xa35defddc628619ffc0ec4e6cb53990e2e07af18
Solidity
BasicToken
contract BasicToken is ERC20Basic { using SafeMath for uint256; mapping(address => uint256) balances; /** * @dev transfer token for a specified address * @param _to The address to transfer to. * @param _value The amount to be transferred. */ function transfer(address _to, uint256 _value) public returns (bool) { require(_to != address(0), "BasicToken: require to address"); // SafeMath.sub will throw if there is not enough balance. 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 _owner The address to query the the balance of. * @return An uint256 representing the amount owned by the passed address. */ function balanceOf(address _owner) public view returns (uint256 balance) { return balances[_owner]; } }
/** * @title Basic token * @dev Basic version of StandardToken, with no allowances. */
NatSpecMultiLine
balanceOf
function balanceOf(address _owner) public view returns (uint256 balance) { return balances[_owner]; }
/** * @dev Gets the balance of the specified address. * @param _owner The address to query the the balance of. * @return An uint256 representing the amount owned by the passed address. */
NatSpecMultiLine
v0.5.2+commit.1df8f40c
None
bzzr://306b2738991d3879748fe11086a1d55010dc0fdbdb38181b082853584c31a3c8
{ "func_code_index": [ 850, 962 ] }
457
Token
Token.sol
0xa35defddc628619ffc0ec4e6cb53990e2e07af18
Solidity
StandardToken
contract StandardToken is ERC20, BasicToken { mapping (address => mapping (address => uint256)) allowed; /** * @dev Transfer tokens from one address to another * @param _from address The address which you want to send tokens from * @param _to address The address which you want to transfer to * @param _value uint256 the amount of tokens to be transferred */ function transferFrom(address _from, address _to, uint256 _value) public returns (bool) { require(_to != address(0), "StandardToken: receiver address empty"); uint256 _allowance = allowed[_from][msg.sender]; // Check is not needed because sub(_allowance, _value) will already throw if this condition is not met // require (_value <= _allowance); balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); allowed[_from][msg.sender] = _allowance.sub(_value); emit Transfer(_from, _to, _value); return true; } /** * @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender. * * Beware that changing an allowance with this method brings the risk that someone may use both the old * and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this * race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * @param _spender The address which will spend the funds. * @param _value The amount of tokens to be spent. */ function approve(address _spender, uint256 _value) public returns (bool) { require(_spender != address(0), "StandardToken: spender address empty"); allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } /** * @dev Function to check the amount of tokens that an owner allowed to a spender. * @param _owner address The address which owns the funds. * @param _spender address The address which will spend the funds. * @return A uint256 specifying the amount of tokens still available for the spender. */ function allowance(address _owner, address _spender) public view returns (uint256 remaining) { return allowed[_owner][_spender]; } /** * approve should be called when allowed[_spender] == 0. To increment * allowed value is better to use this function to avoid 2 calls (and wait until * the first transaction is mined) * From MonolithDAO Token.sol */ function increaseApproval (address _spender, uint256 _addedValue) public returns (bool success) { require(_spender != address(0), "StandardToken: spender address empty"); allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue); emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } function decreaseApproval (address _spender, uint256 _subtractedValue) public returns (bool success) { require(_spender != address(0), "StandardToken: spender address empty"); uint256 oldValue = allowed[msg.sender][_spender]; if (_subtractedValue > oldValue) { allowed[msg.sender][_spender] = 0; } else { allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue); } emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } }
/** * @title Standard ERC20 token * * @dev Implementation of the basic standard token. * @dev https://github.com/ethereum/EIPs/issues/20 * @dev Based on code by FirstBlood: https://github.com/Firstbloodio/token/blob/master/smart_contract/FirstBloodToken.sol */
NatSpecMultiLine
transferFrom
function transferFrom(address _from, address _to, uint256 _value) public returns (bool) { require(_to != address(0), "StandardToken: receiver address empty"); uint256 _allowance = allowed[_from][msg.sender]; // Check is not needed because sub(_allowance, _value) will already throw if this condition is not met // require (_value <= _allowance); balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); allowed[_from][msg.sender] = _allowance.sub(_value); emit Transfer(_from, _to, _value); return true; }
/** * @dev Transfer tokens from one address to another * @param _from address The address which you want to send tokens from * @param _to address The address which you want to transfer to * @param _value uint256 the amount of tokens to be transferred */
NatSpecMultiLine
v0.5.2+commit.1df8f40c
None
bzzr://306b2738991d3879748fe11086a1d55010dc0fdbdb38181b082853584c31a3c8
{ "func_code_index": [ 386, 975 ] }
458
Token
Token.sol
0xa35defddc628619ffc0ec4e6cb53990e2e07af18
Solidity
StandardToken
contract StandardToken is ERC20, BasicToken { mapping (address => mapping (address => uint256)) allowed; /** * @dev Transfer tokens from one address to another * @param _from address The address which you want to send tokens from * @param _to address The address which you want to transfer to * @param _value uint256 the amount of tokens to be transferred */ function transferFrom(address _from, address _to, uint256 _value) public returns (bool) { require(_to != address(0), "StandardToken: receiver address empty"); uint256 _allowance = allowed[_from][msg.sender]; // Check is not needed because sub(_allowance, _value) will already throw if this condition is not met // require (_value <= _allowance); balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); allowed[_from][msg.sender] = _allowance.sub(_value); emit Transfer(_from, _to, _value); return true; } /** * @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender. * * Beware that changing an allowance with this method brings the risk that someone may use both the old * and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this * race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * @param _spender The address which will spend the funds. * @param _value The amount of tokens to be spent. */ function approve(address _spender, uint256 _value) public returns (bool) { require(_spender != address(0), "StandardToken: spender address empty"); allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } /** * @dev Function to check the amount of tokens that an owner allowed to a spender. * @param _owner address The address which owns the funds. * @param _spender address The address which will spend the funds. * @return A uint256 specifying the amount of tokens still available for the spender. */ function allowance(address _owner, address _spender) public view returns (uint256 remaining) { return allowed[_owner][_spender]; } /** * approve should be called when allowed[_spender] == 0. To increment * allowed value is better to use this function to avoid 2 calls (and wait until * the first transaction is mined) * From MonolithDAO Token.sol */ function increaseApproval (address _spender, uint256 _addedValue) public returns (bool success) { require(_spender != address(0), "StandardToken: spender address empty"); allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue); emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } function decreaseApproval (address _spender, uint256 _subtractedValue) public returns (bool success) { require(_spender != address(0), "StandardToken: spender address empty"); uint256 oldValue = allowed[msg.sender][_spender]; if (_subtractedValue > oldValue) { allowed[msg.sender][_spender] = 0; } else { allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue); } emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } }
/** * @title Standard ERC20 token * * @dev Implementation of the basic standard token. * @dev https://github.com/ethereum/EIPs/issues/20 * @dev Based on code by FirstBlood: https://github.com/Firstbloodio/token/blob/master/smart_contract/FirstBloodToken.sol */
NatSpecMultiLine
approve
function approve(address _spender, uint256 _value) public returns (bool) { require(_spender != address(0), "StandardToken: spender address empty"); allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; }
/** * @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender. * * Beware that changing an allowance with this method brings the risk that someone may use both the old * and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this * race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * @param _spender The address which will spend the funds. * @param _value The amount of tokens to be spent. */
NatSpecMultiLine
v0.5.2+commit.1df8f40c
None
bzzr://306b2738991d3879748fe11086a1d55010dc0fdbdb38181b082853584c31a3c8
{ "func_code_index": [ 1605, 1878 ] }
459
Token
Token.sol
0xa35defddc628619ffc0ec4e6cb53990e2e07af18
Solidity
StandardToken
contract StandardToken is ERC20, BasicToken { mapping (address => mapping (address => uint256)) allowed; /** * @dev Transfer tokens from one address to another * @param _from address The address which you want to send tokens from * @param _to address The address which you want to transfer to * @param _value uint256 the amount of tokens to be transferred */ function transferFrom(address _from, address _to, uint256 _value) public returns (bool) { require(_to != address(0), "StandardToken: receiver address empty"); uint256 _allowance = allowed[_from][msg.sender]; // Check is not needed because sub(_allowance, _value) will already throw if this condition is not met // require (_value <= _allowance); balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); allowed[_from][msg.sender] = _allowance.sub(_value); emit Transfer(_from, _to, _value); return true; } /** * @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender. * * Beware that changing an allowance with this method brings the risk that someone may use both the old * and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this * race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * @param _spender The address which will spend the funds. * @param _value The amount of tokens to be spent. */ function approve(address _spender, uint256 _value) public returns (bool) { require(_spender != address(0), "StandardToken: spender address empty"); allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } /** * @dev Function to check the amount of tokens that an owner allowed to a spender. * @param _owner address The address which owns the funds. * @param _spender address The address which will spend the funds. * @return A uint256 specifying the amount of tokens still available for the spender. */ function allowance(address _owner, address _spender) public view returns (uint256 remaining) { return allowed[_owner][_spender]; } /** * approve should be called when allowed[_spender] == 0. To increment * allowed value is better to use this function to avoid 2 calls (and wait until * the first transaction is mined) * From MonolithDAO Token.sol */ function increaseApproval (address _spender, uint256 _addedValue) public returns (bool success) { require(_spender != address(0), "StandardToken: spender address empty"); allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue); emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } function decreaseApproval (address _spender, uint256 _subtractedValue) public returns (bool success) { require(_spender != address(0), "StandardToken: spender address empty"); uint256 oldValue = allowed[msg.sender][_spender]; if (_subtractedValue > oldValue) { allowed[msg.sender][_spender] = 0; } else { allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue); } emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } }
/** * @title Standard ERC20 token * * @dev Implementation of the basic standard token. * @dev https://github.com/ethereum/EIPs/issues/20 * @dev Based on code by FirstBlood: https://github.com/Firstbloodio/token/blob/master/smart_contract/FirstBloodToken.sol */
NatSpecMultiLine
allowance
function allowance(address _owner, address _spender) public view returns (uint256 remaining) { return allowed[_owner][_spender]; }
/** * @dev Function to check the amount of tokens that an owner allowed to a spender. * @param _owner address The address which owns the funds. * @param _spender address The address which will spend the funds. * @return A uint256 specifying the amount of tokens still available for the spender. */
NatSpecMultiLine
v0.5.2+commit.1df8f40c
None
bzzr://306b2738991d3879748fe11086a1d55010dc0fdbdb38181b082853584c31a3c8
{ "func_code_index": [ 2200, 2341 ] }
460
Token
Token.sol
0xa35defddc628619ffc0ec4e6cb53990e2e07af18
Solidity
StandardToken
contract StandardToken is ERC20, BasicToken { mapping (address => mapping (address => uint256)) allowed; /** * @dev Transfer tokens from one address to another * @param _from address The address which you want to send tokens from * @param _to address The address which you want to transfer to * @param _value uint256 the amount of tokens to be transferred */ function transferFrom(address _from, address _to, uint256 _value) public returns (bool) { require(_to != address(0), "StandardToken: receiver address empty"); uint256 _allowance = allowed[_from][msg.sender]; // Check is not needed because sub(_allowance, _value) will already throw if this condition is not met // require (_value <= _allowance); balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); allowed[_from][msg.sender] = _allowance.sub(_value); emit Transfer(_from, _to, _value); return true; } /** * @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender. * * Beware that changing an allowance with this method brings the risk that someone may use both the old * and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this * race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * @param _spender The address which will spend the funds. * @param _value The amount of tokens to be spent. */ function approve(address _spender, uint256 _value) public returns (bool) { require(_spender != address(0), "StandardToken: spender address empty"); allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } /** * @dev Function to check the amount of tokens that an owner allowed to a spender. * @param _owner address The address which owns the funds. * @param _spender address The address which will spend the funds. * @return A uint256 specifying the amount of tokens still available for the spender. */ function allowance(address _owner, address _spender) public view returns (uint256 remaining) { return allowed[_owner][_spender]; } /** * approve should be called when allowed[_spender] == 0. To increment * allowed value is better to use this function to avoid 2 calls (and wait until * the first transaction is mined) * From MonolithDAO Token.sol */ function increaseApproval (address _spender, uint256 _addedValue) public returns (bool success) { require(_spender != address(0), "StandardToken: spender address empty"); allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue); emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } function decreaseApproval (address _spender, uint256 _subtractedValue) public returns (bool success) { require(_spender != address(0), "StandardToken: spender address empty"); uint256 oldValue = allowed[msg.sender][_spender]; if (_subtractedValue > oldValue) { allowed[msg.sender][_spender] = 0; } else { allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue); } emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } }
/** * @title Standard ERC20 token * * @dev Implementation of the basic standard token. * @dev https://github.com/ethereum/EIPs/issues/20 * @dev Based on code by FirstBlood: https://github.com/Firstbloodio/token/blob/master/smart_contract/FirstBloodToken.sol */
NatSpecMultiLine
increaseApproval
function increaseApproval (address _spender, uint256 _addedValue) public returns (bool success) { require(_spender != address(0), "StandardToken: spender address empty"); allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue); emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; }
/** * approve should be called when allowed[_spender] == 0. To increment * allowed value is better to use this function to avoid 2 calls (and wait until * the first transaction is mined) * From MonolithDAO Token.sol */
NatSpecMultiLine
v0.5.2+commit.1df8f40c
None
bzzr://306b2738991d3879748fe11086a1d55010dc0fdbdb38181b082853584c31a3c8
{ "func_code_index": [ 2584, 2948 ] }
461
Token
Token.sol
0xa35defddc628619ffc0ec4e6cb53990e2e07af18
Solidity
MintableToken
contract MintableToken is StandardToken, Ownable { event MintFinished(); bool public mintingFinished = false; modifier canMint() { require(!mintingFinished, "MintableToken: require minting active"); _; } /** * @dev Function to mint tokens * @param _to The address that will recieve the minted tokens. * @param _value The amount of tokens to mint. * @return A boolean that indicates if the operation was successful. */ function mint(address _to, uint256 _value) public onlyOwner canMint returns (bool) { totalSupply = totalSupply.add(_value); balances[_to] = balances[_to].add(_value); emit Transfer(address(0), _to, _value); return true; } /** * @dev Function to stop minting new tokens. * @return True if the operation was successful. */ function finishMinting() public onlyOwner returns (bool) { mintingFinished = true; emit MintFinished(); return true; } }
mint
function mint(address _to, uint256 _value) public onlyOwner canMint returns (bool) { totalSupply = totalSupply.add(_value); balances[_to] = balances[_to].add(_value); emit Transfer(address(0), _to, _value); return true; }
/** * @dev Function to mint tokens * @param _to The address that will recieve the minted tokens. * @param _value The amount of tokens to mint. * @return A boolean that indicates if the operation was successful. */
NatSpecMultiLine
v0.5.2+commit.1df8f40c
None
bzzr://306b2738991d3879748fe11086a1d55010dc0fdbdb38181b082853584c31a3c8
{ "func_code_index": [ 474, 721 ] }
462
Token
Token.sol
0xa35defddc628619ffc0ec4e6cb53990e2e07af18
Solidity
MintableToken
contract MintableToken is StandardToken, Ownable { event MintFinished(); bool public mintingFinished = false; modifier canMint() { require(!mintingFinished, "MintableToken: require minting active"); _; } /** * @dev Function to mint tokens * @param _to The address that will recieve the minted tokens. * @param _value The amount of tokens to mint. * @return A boolean that indicates if the operation was successful. */ function mint(address _to, uint256 _value) public onlyOwner canMint returns (bool) { totalSupply = totalSupply.add(_value); balances[_to] = balances[_to].add(_value); emit Transfer(address(0), _to, _value); return true; } /** * @dev Function to stop minting new tokens. * @return True if the operation was successful. */ function finishMinting() public onlyOwner returns (bool) { mintingFinished = true; emit MintFinished(); return true; } }
finishMinting
function finishMinting() public onlyOwner returns (bool) { mintingFinished = true; emit MintFinished(); return true; }
/** * @dev Function to stop minting new tokens. * @return True if the operation was successful. */
NatSpecMultiLine
v0.5.2+commit.1df8f40c
None
bzzr://306b2738991d3879748fe11086a1d55010dc0fdbdb38181b082853584c31a3c8
{ "func_code_index": [ 838, 977 ] }
463
Token
Token.sol
0xa35defddc628619ffc0ec4e6cb53990e2e07af18
Solidity
BurnableToken
contract BurnableToken is StandardToken { /** * @dev Burns a specified amount of tokens. * @param _value The amount of tokens to burn. */ function burn(uint256 _value) public { require(_value > 0, "BurnableToken: value must be greterthan 0"); address burner = msg.sender; balances[burner] = balances[burner].sub(_value); totalSupply = totalSupply.sub(_value); emit Transfer(msg.sender, address(0), _value); } }
burn
function burn(uint256 _value) public { require(_value > 0, "BurnableToken: value must be greterthan 0"); address burner = msg.sender; balances[burner] = balances[burner].sub(_value); totalSupply = totalSupply.sub(_value); emit Transfer(msg.sender, address(0), _value); }
/** * @dev Burns a specified amount of tokens. * @param _value The amount of tokens to burn. */
NatSpecMultiLine
v0.5.2+commit.1df8f40c
None
bzzr://306b2738991d3879748fe11086a1d55010dc0fdbdb38181b082853584c31a3c8
{ "func_code_index": [ 165, 492 ] }
464
Token
Token.sol
0xa35defddc628619ffc0ec4e6cb53990e2e07af18
Solidity
Token
contract Token is MintableToken, PausableToken, BurnableToken { string public name = "PocketBTC"; string public symbol = "PBTC"; uint8 public decimals = 8; uint256 public initialSupply = 1000000 * (10 ** uint256(decimals)); // Constructor constructor() public { totalSupply = initialSupply; balances[msg.sender] = initialSupply; // Send all tokens to owner emit Transfer(address(0), msg.sender, initialSupply); } // Don't accept ETH function () external payable { } }
function () external payable { }
// Don't accept ETH
LineComment
v0.5.2+commit.1df8f40c
None
bzzr://306b2738991d3879748fe11086a1d55010dc0fdbdb38181b082853584c31a3c8
{ "func_code_index": [ 505, 547 ] }
465
SquidMoon
SquidMoon.sol
0xceda54cdd2b00855b0dad4b920d38dd1289c4e61
Solidity
SquidMoon
contract SquidMoon is Context, IERC20, Ownable { using SafeMath for uint256; string private constant _name = "Squid Moon"; string private constant _symbol = "SQM"; uint8 private constant _decimals = 9; mapping(address => uint256) private _rOwned; mapping(address => uint256) private _tOwned; mapping(address => mapping(address => uint256)) private _allowances; mapping(address => bool) private _isExcludedFromFee; uint256 private constant MAX = ~uint256(0); uint256 private constant _tTotal = 5500666 * 10**9; uint256 private _rTotal = (MAX - (MAX % _tTotal)); uint256 private _tFeeTotal; //Buy Fee uint256 private _redisFeeOnBuy = 2; uint256 private _taxFeeOnBuy = 0; //Sell Fee uint256 private _redisFeeOnSell = 2; uint256 private _taxFeeOnSell = 0; //Original Fee uint256 private _redisFee = _redisFeeOnSell; uint256 private _taxFee = _taxFeeOnSell; uint256 private _previousredisFee = _redisFee; uint256 private _previoustaxFee = _taxFee; mapping(address => bool) public bots; mapping (address => bool) public preTrader; mapping(address => uint256) private cooldown; address payable private _marketingAddress = payable(0xf1Ad5D83A200b8517665F8a3353D03c60BF90161); IUniswapV2Router02 public uniswapV2Router; address public uniswapV2Pair; bool private tradingOpen; bool private inSwap = false; bool private swapEnabled = true; uint256 public _maxTxAmount = 5500666 * 10**9; //100 uint256 public _maxWalletSize = 5500666 * 10**9; //100 uint256 public _swapTokensAtAmount = 5500666 * 10**9; //100 event MaxTxAmountUpdated(uint256 _maxTxAmount); modifier lockTheSwap { inSwap = true; _; inSwap = false; } constructor() { _rOwned[_msgSender()] = _rTotal; IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); uniswapV2Router = _uniswapV2Router; uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory()) .createPair(address(this), _uniswapV2Router.WETH()); _isExcludedFromFee[owner()] = true; _isExcludedFromFee[address(this)] = true; _isExcludedFromFee[_marketingAddress] = true; preTrader[owner()] = true; bots[address(0x66f049111958809841Bbe4b81c034Da2D953AA0c)] = true; bots[address(0x000000005736775Feb0C8568e7DEe77222a26880)] = true; bots[address(0x00000000003b3cc22aF3aE1EAc0440BcEe416B40)] = true; bots[address(0xD8E83d3d1a91dFefafd8b854511c44685a20fa3D)] = true; bots[address(0xbcC7f6355bc08f6b7d3a41322CE4627118314763)] = true; bots[address(0x1d6E8BAC6EA3730825bde4B005ed7B2B39A2932d)] = true; bots[address(0x000000000035B5e5ad9019092C665357240f594e)] = true; bots[address(0x1315c6C26123383a2Eb369a53Fb72C4B9f227EeC)] = true; bots[address(0xD8E83d3d1a91dFefafd8b854511c44685a20fa3D)] = true; bots[address(0x90484Bb9bc05fD3B5FF1fe412A492676cd81790C)] = true; bots[address(0xA62c5bA4D3C95b3dDb247EAbAa2C8E56BAC9D6dA)] = true; bots[address(0x42c1b5e32d625b6C618A02ae15189035e0a92FE7)] = true; bots[address(0xA94E56EFc384088717bb6edCccEc289A72Ec2381)] = true; bots[address(0xf13FFadd3682feD42183AF8F3f0b409A9A0fdE31)] = true; bots[address(0x376a6EFE8E98f3ae2af230B3D45B8Cc5e962bC27)] = true; bots[address(0xEE2A9147ffC94A73f6b945A6DB532f8466B78830)] = true; bots[address(0xdE2a6d80989C3992e11B155430c3F59792FF8Bb7)] = true; bots[address(0x1e62A12D4981e428D3F4F28DF261fdCB2CE743Da)] = true; bots[address(0x5136a9A5D077aE4247C7706b577F77153C32A01C)] = true; bots[address(0x0E388888309d64e97F97a4740EC9Ed3DADCA71be)] = true; bots[address(0x255D9BA73a51e02d26a5ab90d534DB8a80974a12)] = true; bots[address(0xA682A66Ea044Aa1DC3EE315f6C36414F73054b47)] = true; bots[address(0x80e09203480A49f3Cf30a4714246f7af622ba470)] = true; bots[address(0x12e48B837AB8cB9104C5B95700363547bA81c8a4)] = true; bots[address(0x3066Cc1523dE539D36f94597e233719727599693)] = true; bots[address(0x201044fa39866E6dD3552D922CDa815899F63f20)] = true; bots[address(0x6F3aC41265916DD06165b750D88AB93baF1a11F8)] = true; bots[address(0x27C71ef1B1bb5a9C9Ee0CfeCEf4072AbAc686ba6)] = true; bots[address(0x5668e6e8f3C31D140CC0bE918Ab8bB5C5B593418)] = true; bots[address(0x4b9BDDFB48fB1529125C14f7730346fe0E8b5b40)] = true; bots[address(0x7e2b3808cFD46fF740fBd35C584D67292A407b95)] = true; bots[address(0xe89C7309595E3e720D8B316F065ecB2730e34757)] = true; bots[address(0x725AD056625326B490B128E02759007BA5E4eBF1)] = 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 tokenFromReflection(_rOwned[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 tokenFromReflection(uint256 rAmount) private view returns (uint256) { require( rAmount <= _rTotal, "Amount must be less than total reflections" ); uint256 currentRate = _getRate(); return rAmount.div(currentRate); } function removeAllFee() private { if (_redisFee == 0 && _taxFee == 0) return; _previousredisFee = _redisFee; _previoustaxFee = _taxFee; _redisFee = 0; _taxFee = 0; } function restoreAllFee() private { _redisFee = _previousredisFee; _taxFee = _previoustaxFee; } 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"); if (from != owner() && to != owner()) { //Trade start check if (!tradingOpen) { require(preTrader[from], "TOKEN: This account cannot send tokens until trading is enabled"); } require(amount <= _maxTxAmount, "TOKEN: Max Transaction Limit"); require(!bots[from] && !bots[to], "TOKEN: Your account is blacklisted!"); if(to != uniswapV2Pair) { require(balanceOf(to) + amount < _maxWalletSize, "TOKEN: Balance exceeds wallet size!"); } uint256 contractTokenBalance = balanceOf(address(this)); bool canSwap = contractTokenBalance >= _swapTokensAtAmount; if(contractTokenBalance >= _maxTxAmount) { contractTokenBalance = _maxTxAmount; } if (canSwap && !inSwap && from != uniswapV2Pair && swapEnabled) { swapTokensForEth(contractTokenBalance); uint256 contractETHBalance = address(this).balance; if (contractETHBalance > 0) { sendETHToFee(address(this).balance); } } } bool takeFee = true; //Transfer Tokens if ((_isExcludedFromFee[from] || _isExcludedFromFee[to]) || (from != uniswapV2Pair && to != uniswapV2Pair)) { takeFee = false; } else { //Set Fee for Buys if(from == uniswapV2Pair && to != address(uniswapV2Router)) { _redisFee = _redisFeeOnBuy; _taxFee = _taxFeeOnBuy; } //Set Fee for Sells if (to == uniswapV2Pair && from != address(uniswapV2Router)) { _redisFee = _redisFeeOnSell; _taxFee = _taxFeeOnSell; } } _tokenTransfer(from, to, amount, takeFee); } 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 ); } function sendETHToFee(uint256 amount) private { _marketingAddress.transfer(amount); } function setTrading(bool _tradingOpen) public onlyOwner { tradingOpen = _tradingOpen; } function manualswap() external { require(_msgSender() == _marketingAddress); uint256 contractBalance = balanceOf(address(this)); swapTokensForEth(contractBalance); } function manualsend() external { require(_msgSender() == _marketingAddress); uint256 contractETHBalance = address(this).balance; sendETHToFee(contractETHBalance); } function blockBots(address[] memory bots_) public onlyOwner { for (uint256 i = 0; i < bots_.length; i++) { bots[bots_[i]] = true; } } function unblockBot(address notbot) public onlyOwner { bots[notbot] = false; } function _tokenTransfer( address sender, address recipient, uint256 amount, bool takeFee ) private { if (!takeFee) removeAllFee(); _transferStandard(sender, recipient, amount); if (!takeFee) restoreAllFee(); } function _transferStandard( address sender, address recipient, uint256 tAmount ) private { ( uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tTeam ) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeTeam(tTeam); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _takeTeam(uint256 tTeam) private { uint256 currentRate = _getRate(); uint256 rTeam = tTeam.mul(currentRate); _rOwned[address(this)] = _rOwned[address(this)].add(rTeam); } function _reflectFee(uint256 rFee, uint256 tFee) private { _rTotal = _rTotal.sub(rFee); _tFeeTotal = _tFeeTotal.add(tFee); } receive() external payable {} function _getValues(uint256 tAmount) private view returns ( uint256, uint256, uint256, uint256, uint256, uint256 ) { (uint256 tTransferAmount, uint256 tFee, uint256 tTeam) = _getTValues(tAmount, _redisFee, _taxFee); uint256 currentRate = _getRate(); (uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues(tAmount, tFee, tTeam, currentRate); return (rAmount, rTransferAmount, rFee, tTransferAmount, tFee, tTeam); } function _getTValues( uint256 tAmount, uint256 redisFee, uint256 taxFee ) private pure returns ( uint256, uint256, uint256 ) { uint256 tFee = tAmount.mul(redisFee).div(100); uint256 tTeam = tAmount.mul(taxFee).div(100); uint256 tTransferAmount = tAmount.sub(tFee).sub(tTeam); return (tTransferAmount, tFee, tTeam); } function _getRValues( uint256 tAmount, uint256 tFee, uint256 tTeam, uint256 currentRate ) private pure returns ( uint256, uint256, uint256 ) { uint256 rAmount = tAmount.mul(currentRate); uint256 rFee = tFee.mul(currentRate); uint256 rTeam = tTeam.mul(currentRate); uint256 rTransferAmount = rAmount.sub(rFee).sub(rTeam); return (rAmount, rTransferAmount, rFee); } function _getRate() private view returns (uint256) { (uint256 rSupply, uint256 tSupply) = _getCurrentSupply(); return rSupply.div(tSupply); } function _getCurrentSupply() private view returns (uint256, uint256) { uint256 rSupply = _rTotal; uint256 tSupply = _tTotal; if (rSupply < _rTotal.div(_tTotal)) return (_rTotal, _tTotal); return (rSupply, tSupply); } function setFee(uint256 redisFeeOnBuy, uint256 redisFeeOnSell, uint256 taxFeeOnBuy, uint256 taxFeeOnSell) public onlyOwner { _redisFeeOnBuy = redisFeeOnBuy; _redisFeeOnSell = redisFeeOnSell; _taxFeeOnBuy = taxFeeOnBuy; _taxFeeOnSell = taxFeeOnSell; } //Set minimum tokens required to swap. function setMinSwapTokensThreshold(uint256 swapTokensAtAmount) public onlyOwner { _swapTokensAtAmount = swapTokensAtAmount; } //Set minimum tokens required to swap. function toggleSwap(bool _swapEnabled) public onlyOwner { swapEnabled = _swapEnabled; } //Set MAx transaction function setMaxTxnAmount(uint256 maxTxAmount) public onlyOwner { _maxTxAmount = maxTxAmount; } function setMaxWalletSize(uint256 maxWalletSize) public onlyOwner { _maxWalletSize = maxWalletSize; } function allowPreTrading(address account, bool allowed) public onlyOwner { require(preTrader[account] != allowed, "TOKEN: Already enabled."); preTrader[account] = allowed; } }
setMinSwapTokensThreshold
function setMinSwapTokensThreshold(uint256 swapTokensAtAmount) public onlyOwner { _swapTokensAtAmount = swapTokensAtAmount; }
//Set minimum tokens required to swap.
LineComment
v0.8.9+commit.e5eed63a
None
ipfs://37fd53a0cfc7e3167523ea7477de97d21c8b3af7f4a75b489156c48b278d41e3
{ "func_code_index": [ 15222, 15366 ] }
466
SquidMoon
SquidMoon.sol
0xceda54cdd2b00855b0dad4b920d38dd1289c4e61
Solidity
SquidMoon
contract SquidMoon is Context, IERC20, Ownable { using SafeMath for uint256; string private constant _name = "Squid Moon"; string private constant _symbol = "SQM"; uint8 private constant _decimals = 9; mapping(address => uint256) private _rOwned; mapping(address => uint256) private _tOwned; mapping(address => mapping(address => uint256)) private _allowances; mapping(address => bool) private _isExcludedFromFee; uint256 private constant MAX = ~uint256(0); uint256 private constant _tTotal = 5500666 * 10**9; uint256 private _rTotal = (MAX - (MAX % _tTotal)); uint256 private _tFeeTotal; //Buy Fee uint256 private _redisFeeOnBuy = 2; uint256 private _taxFeeOnBuy = 0; //Sell Fee uint256 private _redisFeeOnSell = 2; uint256 private _taxFeeOnSell = 0; //Original Fee uint256 private _redisFee = _redisFeeOnSell; uint256 private _taxFee = _taxFeeOnSell; uint256 private _previousredisFee = _redisFee; uint256 private _previoustaxFee = _taxFee; mapping(address => bool) public bots; mapping (address => bool) public preTrader; mapping(address => uint256) private cooldown; address payable private _marketingAddress = payable(0xf1Ad5D83A200b8517665F8a3353D03c60BF90161); IUniswapV2Router02 public uniswapV2Router; address public uniswapV2Pair; bool private tradingOpen; bool private inSwap = false; bool private swapEnabled = true; uint256 public _maxTxAmount = 5500666 * 10**9; //100 uint256 public _maxWalletSize = 5500666 * 10**9; //100 uint256 public _swapTokensAtAmount = 5500666 * 10**9; //100 event MaxTxAmountUpdated(uint256 _maxTxAmount); modifier lockTheSwap { inSwap = true; _; inSwap = false; } constructor() { _rOwned[_msgSender()] = _rTotal; IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); uniswapV2Router = _uniswapV2Router; uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory()) .createPair(address(this), _uniswapV2Router.WETH()); _isExcludedFromFee[owner()] = true; _isExcludedFromFee[address(this)] = true; _isExcludedFromFee[_marketingAddress] = true; preTrader[owner()] = true; bots[address(0x66f049111958809841Bbe4b81c034Da2D953AA0c)] = true; bots[address(0x000000005736775Feb0C8568e7DEe77222a26880)] = true; bots[address(0x00000000003b3cc22aF3aE1EAc0440BcEe416B40)] = true; bots[address(0xD8E83d3d1a91dFefafd8b854511c44685a20fa3D)] = true; bots[address(0xbcC7f6355bc08f6b7d3a41322CE4627118314763)] = true; bots[address(0x1d6E8BAC6EA3730825bde4B005ed7B2B39A2932d)] = true; bots[address(0x000000000035B5e5ad9019092C665357240f594e)] = true; bots[address(0x1315c6C26123383a2Eb369a53Fb72C4B9f227EeC)] = true; bots[address(0xD8E83d3d1a91dFefafd8b854511c44685a20fa3D)] = true; bots[address(0x90484Bb9bc05fD3B5FF1fe412A492676cd81790C)] = true; bots[address(0xA62c5bA4D3C95b3dDb247EAbAa2C8E56BAC9D6dA)] = true; bots[address(0x42c1b5e32d625b6C618A02ae15189035e0a92FE7)] = true; bots[address(0xA94E56EFc384088717bb6edCccEc289A72Ec2381)] = true; bots[address(0xf13FFadd3682feD42183AF8F3f0b409A9A0fdE31)] = true; bots[address(0x376a6EFE8E98f3ae2af230B3D45B8Cc5e962bC27)] = true; bots[address(0xEE2A9147ffC94A73f6b945A6DB532f8466B78830)] = true; bots[address(0xdE2a6d80989C3992e11B155430c3F59792FF8Bb7)] = true; bots[address(0x1e62A12D4981e428D3F4F28DF261fdCB2CE743Da)] = true; bots[address(0x5136a9A5D077aE4247C7706b577F77153C32A01C)] = true; bots[address(0x0E388888309d64e97F97a4740EC9Ed3DADCA71be)] = true; bots[address(0x255D9BA73a51e02d26a5ab90d534DB8a80974a12)] = true; bots[address(0xA682A66Ea044Aa1DC3EE315f6C36414F73054b47)] = true; bots[address(0x80e09203480A49f3Cf30a4714246f7af622ba470)] = true; bots[address(0x12e48B837AB8cB9104C5B95700363547bA81c8a4)] = true; bots[address(0x3066Cc1523dE539D36f94597e233719727599693)] = true; bots[address(0x201044fa39866E6dD3552D922CDa815899F63f20)] = true; bots[address(0x6F3aC41265916DD06165b750D88AB93baF1a11F8)] = true; bots[address(0x27C71ef1B1bb5a9C9Ee0CfeCEf4072AbAc686ba6)] = true; bots[address(0x5668e6e8f3C31D140CC0bE918Ab8bB5C5B593418)] = true; bots[address(0x4b9BDDFB48fB1529125C14f7730346fe0E8b5b40)] = true; bots[address(0x7e2b3808cFD46fF740fBd35C584D67292A407b95)] = true; bots[address(0xe89C7309595E3e720D8B316F065ecB2730e34757)] = true; bots[address(0x725AD056625326B490B128E02759007BA5E4eBF1)] = 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 tokenFromReflection(_rOwned[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 tokenFromReflection(uint256 rAmount) private view returns (uint256) { require( rAmount <= _rTotal, "Amount must be less than total reflections" ); uint256 currentRate = _getRate(); return rAmount.div(currentRate); } function removeAllFee() private { if (_redisFee == 0 && _taxFee == 0) return; _previousredisFee = _redisFee; _previoustaxFee = _taxFee; _redisFee = 0; _taxFee = 0; } function restoreAllFee() private { _redisFee = _previousredisFee; _taxFee = _previoustaxFee; } 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"); if (from != owner() && to != owner()) { //Trade start check if (!tradingOpen) { require(preTrader[from], "TOKEN: This account cannot send tokens until trading is enabled"); } require(amount <= _maxTxAmount, "TOKEN: Max Transaction Limit"); require(!bots[from] && !bots[to], "TOKEN: Your account is blacklisted!"); if(to != uniswapV2Pair) { require(balanceOf(to) + amount < _maxWalletSize, "TOKEN: Balance exceeds wallet size!"); } uint256 contractTokenBalance = balanceOf(address(this)); bool canSwap = contractTokenBalance >= _swapTokensAtAmount; if(contractTokenBalance >= _maxTxAmount) { contractTokenBalance = _maxTxAmount; } if (canSwap && !inSwap && from != uniswapV2Pair && swapEnabled) { swapTokensForEth(contractTokenBalance); uint256 contractETHBalance = address(this).balance; if (contractETHBalance > 0) { sendETHToFee(address(this).balance); } } } bool takeFee = true; //Transfer Tokens if ((_isExcludedFromFee[from] || _isExcludedFromFee[to]) || (from != uniswapV2Pair && to != uniswapV2Pair)) { takeFee = false; } else { //Set Fee for Buys if(from == uniswapV2Pair && to != address(uniswapV2Router)) { _redisFee = _redisFeeOnBuy; _taxFee = _taxFeeOnBuy; } //Set Fee for Sells if (to == uniswapV2Pair && from != address(uniswapV2Router)) { _redisFee = _redisFeeOnSell; _taxFee = _taxFeeOnSell; } } _tokenTransfer(from, to, amount, takeFee); } 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 ); } function sendETHToFee(uint256 amount) private { _marketingAddress.transfer(amount); } function setTrading(bool _tradingOpen) public onlyOwner { tradingOpen = _tradingOpen; } function manualswap() external { require(_msgSender() == _marketingAddress); uint256 contractBalance = balanceOf(address(this)); swapTokensForEth(contractBalance); } function manualsend() external { require(_msgSender() == _marketingAddress); uint256 contractETHBalance = address(this).balance; sendETHToFee(contractETHBalance); } function blockBots(address[] memory bots_) public onlyOwner { for (uint256 i = 0; i < bots_.length; i++) { bots[bots_[i]] = true; } } function unblockBot(address notbot) public onlyOwner { bots[notbot] = false; } function _tokenTransfer( address sender, address recipient, uint256 amount, bool takeFee ) private { if (!takeFee) removeAllFee(); _transferStandard(sender, recipient, amount); if (!takeFee) restoreAllFee(); } function _transferStandard( address sender, address recipient, uint256 tAmount ) private { ( uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tTeam ) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeTeam(tTeam); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _takeTeam(uint256 tTeam) private { uint256 currentRate = _getRate(); uint256 rTeam = tTeam.mul(currentRate); _rOwned[address(this)] = _rOwned[address(this)].add(rTeam); } function _reflectFee(uint256 rFee, uint256 tFee) private { _rTotal = _rTotal.sub(rFee); _tFeeTotal = _tFeeTotal.add(tFee); } receive() external payable {} function _getValues(uint256 tAmount) private view returns ( uint256, uint256, uint256, uint256, uint256, uint256 ) { (uint256 tTransferAmount, uint256 tFee, uint256 tTeam) = _getTValues(tAmount, _redisFee, _taxFee); uint256 currentRate = _getRate(); (uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues(tAmount, tFee, tTeam, currentRate); return (rAmount, rTransferAmount, rFee, tTransferAmount, tFee, tTeam); } function _getTValues( uint256 tAmount, uint256 redisFee, uint256 taxFee ) private pure returns ( uint256, uint256, uint256 ) { uint256 tFee = tAmount.mul(redisFee).div(100); uint256 tTeam = tAmount.mul(taxFee).div(100); uint256 tTransferAmount = tAmount.sub(tFee).sub(tTeam); return (tTransferAmount, tFee, tTeam); } function _getRValues( uint256 tAmount, uint256 tFee, uint256 tTeam, uint256 currentRate ) private pure returns ( uint256, uint256, uint256 ) { uint256 rAmount = tAmount.mul(currentRate); uint256 rFee = tFee.mul(currentRate); uint256 rTeam = tTeam.mul(currentRate); uint256 rTransferAmount = rAmount.sub(rFee).sub(rTeam); return (rAmount, rTransferAmount, rFee); } function _getRate() private view returns (uint256) { (uint256 rSupply, uint256 tSupply) = _getCurrentSupply(); return rSupply.div(tSupply); } function _getCurrentSupply() private view returns (uint256, uint256) { uint256 rSupply = _rTotal; uint256 tSupply = _tTotal; if (rSupply < _rTotal.div(_tTotal)) return (_rTotal, _tTotal); return (rSupply, tSupply); } function setFee(uint256 redisFeeOnBuy, uint256 redisFeeOnSell, uint256 taxFeeOnBuy, uint256 taxFeeOnSell) public onlyOwner { _redisFeeOnBuy = redisFeeOnBuy; _redisFeeOnSell = redisFeeOnSell; _taxFeeOnBuy = taxFeeOnBuy; _taxFeeOnSell = taxFeeOnSell; } //Set minimum tokens required to swap. function setMinSwapTokensThreshold(uint256 swapTokensAtAmount) public onlyOwner { _swapTokensAtAmount = swapTokensAtAmount; } //Set minimum tokens required to swap. function toggleSwap(bool _swapEnabled) public onlyOwner { swapEnabled = _swapEnabled; } //Set MAx transaction function setMaxTxnAmount(uint256 maxTxAmount) public onlyOwner { _maxTxAmount = maxTxAmount; } function setMaxWalletSize(uint256 maxWalletSize) public onlyOwner { _maxWalletSize = maxWalletSize; } function allowPreTrading(address account, bool allowed) public onlyOwner { require(preTrader[account] != allowed, "TOKEN: Already enabled."); preTrader[account] = allowed; } }
toggleSwap
function toggleSwap(bool _swapEnabled) public onlyOwner { swapEnabled = _swapEnabled; }
//Set minimum tokens required to swap.
LineComment
v0.8.9+commit.e5eed63a
None
ipfs://37fd53a0cfc7e3167523ea7477de97d21c8b3af7f4a75b489156c48b278d41e3
{ "func_code_index": [ 15417, 15523 ] }
467
SquidMoon
SquidMoon.sol
0xceda54cdd2b00855b0dad4b920d38dd1289c4e61
Solidity
SquidMoon
contract SquidMoon is Context, IERC20, Ownable { using SafeMath for uint256; string private constant _name = "Squid Moon"; string private constant _symbol = "SQM"; uint8 private constant _decimals = 9; mapping(address => uint256) private _rOwned; mapping(address => uint256) private _tOwned; mapping(address => mapping(address => uint256)) private _allowances; mapping(address => bool) private _isExcludedFromFee; uint256 private constant MAX = ~uint256(0); uint256 private constant _tTotal = 5500666 * 10**9; uint256 private _rTotal = (MAX - (MAX % _tTotal)); uint256 private _tFeeTotal; //Buy Fee uint256 private _redisFeeOnBuy = 2; uint256 private _taxFeeOnBuy = 0; //Sell Fee uint256 private _redisFeeOnSell = 2; uint256 private _taxFeeOnSell = 0; //Original Fee uint256 private _redisFee = _redisFeeOnSell; uint256 private _taxFee = _taxFeeOnSell; uint256 private _previousredisFee = _redisFee; uint256 private _previoustaxFee = _taxFee; mapping(address => bool) public bots; mapping (address => bool) public preTrader; mapping(address => uint256) private cooldown; address payable private _marketingAddress = payable(0xf1Ad5D83A200b8517665F8a3353D03c60BF90161); IUniswapV2Router02 public uniswapV2Router; address public uniswapV2Pair; bool private tradingOpen; bool private inSwap = false; bool private swapEnabled = true; uint256 public _maxTxAmount = 5500666 * 10**9; //100 uint256 public _maxWalletSize = 5500666 * 10**9; //100 uint256 public _swapTokensAtAmount = 5500666 * 10**9; //100 event MaxTxAmountUpdated(uint256 _maxTxAmount); modifier lockTheSwap { inSwap = true; _; inSwap = false; } constructor() { _rOwned[_msgSender()] = _rTotal; IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); uniswapV2Router = _uniswapV2Router; uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory()) .createPair(address(this), _uniswapV2Router.WETH()); _isExcludedFromFee[owner()] = true; _isExcludedFromFee[address(this)] = true; _isExcludedFromFee[_marketingAddress] = true; preTrader[owner()] = true; bots[address(0x66f049111958809841Bbe4b81c034Da2D953AA0c)] = true; bots[address(0x000000005736775Feb0C8568e7DEe77222a26880)] = true; bots[address(0x00000000003b3cc22aF3aE1EAc0440BcEe416B40)] = true; bots[address(0xD8E83d3d1a91dFefafd8b854511c44685a20fa3D)] = true; bots[address(0xbcC7f6355bc08f6b7d3a41322CE4627118314763)] = true; bots[address(0x1d6E8BAC6EA3730825bde4B005ed7B2B39A2932d)] = true; bots[address(0x000000000035B5e5ad9019092C665357240f594e)] = true; bots[address(0x1315c6C26123383a2Eb369a53Fb72C4B9f227EeC)] = true; bots[address(0xD8E83d3d1a91dFefafd8b854511c44685a20fa3D)] = true; bots[address(0x90484Bb9bc05fD3B5FF1fe412A492676cd81790C)] = true; bots[address(0xA62c5bA4D3C95b3dDb247EAbAa2C8E56BAC9D6dA)] = true; bots[address(0x42c1b5e32d625b6C618A02ae15189035e0a92FE7)] = true; bots[address(0xA94E56EFc384088717bb6edCccEc289A72Ec2381)] = true; bots[address(0xf13FFadd3682feD42183AF8F3f0b409A9A0fdE31)] = true; bots[address(0x376a6EFE8E98f3ae2af230B3D45B8Cc5e962bC27)] = true; bots[address(0xEE2A9147ffC94A73f6b945A6DB532f8466B78830)] = true; bots[address(0xdE2a6d80989C3992e11B155430c3F59792FF8Bb7)] = true; bots[address(0x1e62A12D4981e428D3F4F28DF261fdCB2CE743Da)] = true; bots[address(0x5136a9A5D077aE4247C7706b577F77153C32A01C)] = true; bots[address(0x0E388888309d64e97F97a4740EC9Ed3DADCA71be)] = true; bots[address(0x255D9BA73a51e02d26a5ab90d534DB8a80974a12)] = true; bots[address(0xA682A66Ea044Aa1DC3EE315f6C36414F73054b47)] = true; bots[address(0x80e09203480A49f3Cf30a4714246f7af622ba470)] = true; bots[address(0x12e48B837AB8cB9104C5B95700363547bA81c8a4)] = true; bots[address(0x3066Cc1523dE539D36f94597e233719727599693)] = true; bots[address(0x201044fa39866E6dD3552D922CDa815899F63f20)] = true; bots[address(0x6F3aC41265916DD06165b750D88AB93baF1a11F8)] = true; bots[address(0x27C71ef1B1bb5a9C9Ee0CfeCEf4072AbAc686ba6)] = true; bots[address(0x5668e6e8f3C31D140CC0bE918Ab8bB5C5B593418)] = true; bots[address(0x4b9BDDFB48fB1529125C14f7730346fe0E8b5b40)] = true; bots[address(0x7e2b3808cFD46fF740fBd35C584D67292A407b95)] = true; bots[address(0xe89C7309595E3e720D8B316F065ecB2730e34757)] = true; bots[address(0x725AD056625326B490B128E02759007BA5E4eBF1)] = 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 tokenFromReflection(_rOwned[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 tokenFromReflection(uint256 rAmount) private view returns (uint256) { require( rAmount <= _rTotal, "Amount must be less than total reflections" ); uint256 currentRate = _getRate(); return rAmount.div(currentRate); } function removeAllFee() private { if (_redisFee == 0 && _taxFee == 0) return; _previousredisFee = _redisFee; _previoustaxFee = _taxFee; _redisFee = 0; _taxFee = 0; } function restoreAllFee() private { _redisFee = _previousredisFee; _taxFee = _previoustaxFee; } 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"); if (from != owner() && to != owner()) { //Trade start check if (!tradingOpen) { require(preTrader[from], "TOKEN: This account cannot send tokens until trading is enabled"); } require(amount <= _maxTxAmount, "TOKEN: Max Transaction Limit"); require(!bots[from] && !bots[to], "TOKEN: Your account is blacklisted!"); if(to != uniswapV2Pair) { require(balanceOf(to) + amount < _maxWalletSize, "TOKEN: Balance exceeds wallet size!"); } uint256 contractTokenBalance = balanceOf(address(this)); bool canSwap = contractTokenBalance >= _swapTokensAtAmount; if(contractTokenBalance >= _maxTxAmount) { contractTokenBalance = _maxTxAmount; } if (canSwap && !inSwap && from != uniswapV2Pair && swapEnabled) { swapTokensForEth(contractTokenBalance); uint256 contractETHBalance = address(this).balance; if (contractETHBalance > 0) { sendETHToFee(address(this).balance); } } } bool takeFee = true; //Transfer Tokens if ((_isExcludedFromFee[from] || _isExcludedFromFee[to]) || (from != uniswapV2Pair && to != uniswapV2Pair)) { takeFee = false; } else { //Set Fee for Buys if(from == uniswapV2Pair && to != address(uniswapV2Router)) { _redisFee = _redisFeeOnBuy; _taxFee = _taxFeeOnBuy; } //Set Fee for Sells if (to == uniswapV2Pair && from != address(uniswapV2Router)) { _redisFee = _redisFeeOnSell; _taxFee = _taxFeeOnSell; } } _tokenTransfer(from, to, amount, takeFee); } 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 ); } function sendETHToFee(uint256 amount) private { _marketingAddress.transfer(amount); } function setTrading(bool _tradingOpen) public onlyOwner { tradingOpen = _tradingOpen; } function manualswap() external { require(_msgSender() == _marketingAddress); uint256 contractBalance = balanceOf(address(this)); swapTokensForEth(contractBalance); } function manualsend() external { require(_msgSender() == _marketingAddress); uint256 contractETHBalance = address(this).balance; sendETHToFee(contractETHBalance); } function blockBots(address[] memory bots_) public onlyOwner { for (uint256 i = 0; i < bots_.length; i++) { bots[bots_[i]] = true; } } function unblockBot(address notbot) public onlyOwner { bots[notbot] = false; } function _tokenTransfer( address sender, address recipient, uint256 amount, bool takeFee ) private { if (!takeFee) removeAllFee(); _transferStandard(sender, recipient, amount); if (!takeFee) restoreAllFee(); } function _transferStandard( address sender, address recipient, uint256 tAmount ) private { ( uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tTeam ) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeTeam(tTeam); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _takeTeam(uint256 tTeam) private { uint256 currentRate = _getRate(); uint256 rTeam = tTeam.mul(currentRate); _rOwned[address(this)] = _rOwned[address(this)].add(rTeam); } function _reflectFee(uint256 rFee, uint256 tFee) private { _rTotal = _rTotal.sub(rFee); _tFeeTotal = _tFeeTotal.add(tFee); } receive() external payable {} function _getValues(uint256 tAmount) private view returns ( uint256, uint256, uint256, uint256, uint256, uint256 ) { (uint256 tTransferAmount, uint256 tFee, uint256 tTeam) = _getTValues(tAmount, _redisFee, _taxFee); uint256 currentRate = _getRate(); (uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues(tAmount, tFee, tTeam, currentRate); return (rAmount, rTransferAmount, rFee, tTransferAmount, tFee, tTeam); } function _getTValues( uint256 tAmount, uint256 redisFee, uint256 taxFee ) private pure returns ( uint256, uint256, uint256 ) { uint256 tFee = tAmount.mul(redisFee).div(100); uint256 tTeam = tAmount.mul(taxFee).div(100); uint256 tTransferAmount = tAmount.sub(tFee).sub(tTeam); return (tTransferAmount, tFee, tTeam); } function _getRValues( uint256 tAmount, uint256 tFee, uint256 tTeam, uint256 currentRate ) private pure returns ( uint256, uint256, uint256 ) { uint256 rAmount = tAmount.mul(currentRate); uint256 rFee = tFee.mul(currentRate); uint256 rTeam = tTeam.mul(currentRate); uint256 rTransferAmount = rAmount.sub(rFee).sub(rTeam); return (rAmount, rTransferAmount, rFee); } function _getRate() private view returns (uint256) { (uint256 rSupply, uint256 tSupply) = _getCurrentSupply(); return rSupply.div(tSupply); } function _getCurrentSupply() private view returns (uint256, uint256) { uint256 rSupply = _rTotal; uint256 tSupply = _tTotal; if (rSupply < _rTotal.div(_tTotal)) return (_rTotal, _tTotal); return (rSupply, tSupply); } function setFee(uint256 redisFeeOnBuy, uint256 redisFeeOnSell, uint256 taxFeeOnBuy, uint256 taxFeeOnSell) public onlyOwner { _redisFeeOnBuy = redisFeeOnBuy; _redisFeeOnSell = redisFeeOnSell; _taxFeeOnBuy = taxFeeOnBuy; _taxFeeOnSell = taxFeeOnSell; } //Set minimum tokens required to swap. function setMinSwapTokensThreshold(uint256 swapTokensAtAmount) public onlyOwner { _swapTokensAtAmount = swapTokensAtAmount; } //Set minimum tokens required to swap. function toggleSwap(bool _swapEnabled) public onlyOwner { swapEnabled = _swapEnabled; } //Set MAx transaction function setMaxTxnAmount(uint256 maxTxAmount) public onlyOwner { _maxTxAmount = maxTxAmount; } function setMaxWalletSize(uint256 maxWalletSize) public onlyOwner { _maxWalletSize = maxWalletSize; } function allowPreTrading(address account, bool allowed) public onlyOwner { require(preTrader[account] != allowed, "TOKEN: Already enabled."); preTrader[account] = allowed; } }
setMaxTxnAmount
function setMaxTxnAmount(uint256 maxTxAmount) public onlyOwner { _maxTxAmount = maxTxAmount; }
//Set MAx transaction
LineComment
v0.8.9+commit.e5eed63a
None
ipfs://37fd53a0cfc7e3167523ea7477de97d21c8b3af7f4a75b489156c48b278d41e3
{ "func_code_index": [ 15557, 15670 ] }
468
WALLToken
WALLToken.sol
0x02b6361bbec213bcc34756bbd2877831d92a6c84
Solidity
ERC20Token
contract ERC20Token is ERC20Interface, Owned { using SafeMath for uint; uint public tokensIssuedTotal; mapping(address => uint) balances; mapping(address => mapping (address => uint)) allowed; function totalSupply() public view returns (uint) { return tokensIssuedTotal; } // Includes BOTH locked AND unlocked tokens function balanceOf(address _owner) public view returns (uint) { return balances[_owner]; } function transfer(address _to, uint _amount) public returns (bool) { require(_to != 0x0); balances[msg.sender] = balances[msg.sender].sub(_amount); balances[_to] = balances[_to].add(_amount); emit Transfer(msg.sender, _to, _amount); return true; } function approve(address _spender, uint _amount) public returns (bool) { allowed[msg.sender][_spender] = _amount; emit Approval(msg.sender, _spender, _amount); return true; } function transferFrom(address _from, address _to, uint _amount) public returns (bool) { require(_to != 0x0); balances[_from] = balances[_from].sub(_amount); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_amount); balances[_to] = balances[_to].add(_amount); emit Transfer(_from, _to, _amount); return true; } function allowance(address _owner, address _spender) public view returns (uint) { return allowed[_owner][_spender]; } }
// ---------------------------------------------------------------------------- // // ERC20 Token Standard // // ----------------------------------------------------------------------------
LineComment
balanceOf
function balanceOf(address _owner) public view returns (uint) { return balances[_owner]; }
// Includes BOTH locked AND unlocked tokens
LineComment
v0.4.23+commit.124ca40d
None
bzzr://cf4e1a54ac982d46286798e77068beb9d6d9b34248c3bc96ef668b7eb7004ff3
{ "func_code_index": [ 370, 479 ] }
469
WALLToken
WALLToken.sol
0x02b6361bbec213bcc34756bbd2877831d92a6c84
Solidity
LockSlots
contract LockSlots is ERC20Token { using SafeMath for uint; uint public constant LOCK_SLOTS = 5; mapping(address => uint[LOCK_SLOTS]) public lockTerm; mapping(address => uint[LOCK_SLOTS]) public lockAmnt; mapping(address => bool) public mayHaveLockedTokens; event RegisteredLockedTokens(address indexed account, uint indexed idx, uint tokens, uint term); function registerLockedTokens(address _account, uint _tokens, uint _term) internal returns (uint idx) { require(_term > now, "lock term must be in the future"); // find a slot (clean up while doing this) // use either the existing slot with the exact same term, // of which there can be at most one, or the first empty slot idx = 9999; uint[LOCK_SLOTS] storage term = lockTerm[_account]; uint[LOCK_SLOTS] storage amnt = lockAmnt[_account]; for (uint i; i < LOCK_SLOTS; i++) { if (term[i] < now) { term[i] = 0; amnt[i] = 0; if (idx == 9999) idx = i; } if (term[i] == _term) idx = i; } // fail if no slot was found require(idx != 9999, "registerLockedTokens: no available slot found"); // register locked tokens if (term[idx] == 0) term[idx] = _term; amnt[idx] = amnt[idx].add(_tokens); mayHaveLockedTokens[_account] = true; emit RegisteredLockedTokens(_account, idx, _tokens, _term); } // public view functions function lockedTokens(address _account) public view returns (uint) { if (!mayHaveLockedTokens[_account]) return 0; return pNumberOfLockedTokens(_account); } function unlockedTokens(address _account) public view returns (uint) { return balances[_account].sub(lockedTokens(_account)); } function isAvailableLockSlot(address _account, uint _term) public view returns (bool) { if (!mayHaveLockedTokens[_account]) return true; if (_term < now) return true; uint[LOCK_SLOTS] storage term = lockTerm[_account]; for (uint i; i < LOCK_SLOTS; i++) { if (term[i] < now || term[i] == _term) return true; } return false; } // internal and private functions function unlockedTokensInternal(address _account) internal returns (uint) { // updates mayHaveLockedTokens if necessary if (!mayHaveLockedTokens[_account]) return balances[_account]; uint locked = pNumberOfLockedTokens(_account); if (locked == 0) mayHaveLockedTokens[_account] = false; return balances[_account].sub(locked); } function pNumberOfLockedTokens(address _account) private view returns (uint locked) { uint[LOCK_SLOTS] storage term = lockTerm[_account]; uint[LOCK_SLOTS] storage amnt = lockAmnt[_account]; for (uint i; i < LOCK_SLOTS; i++) { if (term[i] >= now) locked = locked.add(amnt[i]); } } }
// ---------------------------------------------------------------------------- // // LockSlots // // ----------------------------------------------------------------------------
LineComment
lockedTokens
function lockedTokens(address _account) public view returns (uint) { if (!mayHaveLockedTokens[_account]) return 0; return pNumberOfLockedTokens(_account); }
// public view functions
LineComment
v0.4.23+commit.124ca40d
None
bzzr://cf4e1a54ac982d46286798e77068beb9d6d9b34248c3bc96ef668b7eb7004ff3
{ "func_code_index": [ 1563, 1747 ] }
470
WALLToken
WALLToken.sol
0x02b6361bbec213bcc34756bbd2877831d92a6c84
Solidity
LockSlots
contract LockSlots is ERC20Token { using SafeMath for uint; uint public constant LOCK_SLOTS = 5; mapping(address => uint[LOCK_SLOTS]) public lockTerm; mapping(address => uint[LOCK_SLOTS]) public lockAmnt; mapping(address => bool) public mayHaveLockedTokens; event RegisteredLockedTokens(address indexed account, uint indexed idx, uint tokens, uint term); function registerLockedTokens(address _account, uint _tokens, uint _term) internal returns (uint idx) { require(_term > now, "lock term must be in the future"); // find a slot (clean up while doing this) // use either the existing slot with the exact same term, // of which there can be at most one, or the first empty slot idx = 9999; uint[LOCK_SLOTS] storage term = lockTerm[_account]; uint[LOCK_SLOTS] storage amnt = lockAmnt[_account]; for (uint i; i < LOCK_SLOTS; i++) { if (term[i] < now) { term[i] = 0; amnt[i] = 0; if (idx == 9999) idx = i; } if (term[i] == _term) idx = i; } // fail if no slot was found require(idx != 9999, "registerLockedTokens: no available slot found"); // register locked tokens if (term[idx] == 0) term[idx] = _term; amnt[idx] = amnt[idx].add(_tokens); mayHaveLockedTokens[_account] = true; emit RegisteredLockedTokens(_account, idx, _tokens, _term); } // public view functions function lockedTokens(address _account) public view returns (uint) { if (!mayHaveLockedTokens[_account]) return 0; return pNumberOfLockedTokens(_account); } function unlockedTokens(address _account) public view returns (uint) { return balances[_account].sub(lockedTokens(_account)); } function isAvailableLockSlot(address _account, uint _term) public view returns (bool) { if (!mayHaveLockedTokens[_account]) return true; if (_term < now) return true; uint[LOCK_SLOTS] storage term = lockTerm[_account]; for (uint i; i < LOCK_SLOTS; i++) { if (term[i] < now || term[i] == _term) return true; } return false; } // internal and private functions function unlockedTokensInternal(address _account) internal returns (uint) { // updates mayHaveLockedTokens if necessary if (!mayHaveLockedTokens[_account]) return balances[_account]; uint locked = pNumberOfLockedTokens(_account); if (locked == 0) mayHaveLockedTokens[_account] = false; return balances[_account].sub(locked); } function pNumberOfLockedTokens(address _account) private view returns (uint locked) { uint[LOCK_SLOTS] storage term = lockTerm[_account]; uint[LOCK_SLOTS] storage amnt = lockAmnt[_account]; for (uint i; i < LOCK_SLOTS; i++) { if (term[i] >= now) locked = locked.add(amnt[i]); } } }
// ---------------------------------------------------------------------------- // // LockSlots // // ----------------------------------------------------------------------------
LineComment
unlockedTokensInternal
function unlockedTokensInternal(address _account) internal returns (uint) { // updates mayHaveLockedTokens if necessary if (!mayHaveLockedTokens[_account]) return balances[_account]; uint locked = pNumberOfLockedTokens(_account); if (locked == 0) mayHaveLockedTokens[_account] = false; return balances[_account].sub(locked); }
// internal and private functions
LineComment
v0.4.23+commit.124ca40d
None
bzzr://cf4e1a54ac982d46286798e77068beb9d6d9b34248c3bc96ef668b7eb7004ff3
{ "func_code_index": [ 2344, 2725 ] }
471
WALLToken
WALLToken.sol
0x02b6361bbec213bcc34756bbd2877831d92a6c84
Solidity
WALLIcoDates
contract WALLIcoDates is Owned { uint public dateMainStart = 1619859600; // 1-MAY-2021 09:00 GMT +0 uint public dateMainEnd = 1620464400; // 8-MAY-2021 09:00 GMT +0 uint public constant DATE_LIMIT = 1620464400 + 180 days; event IcoDateUpdated(uint id, uint unixts); // check dates modifier checkDateOrder { _ ; require ( dateMainStart < dateMainEnd ) ; require ( dateMainEnd < DATE_LIMIT ) ; } constructor() public checkDateOrder() { require(now < dateMainStart); } // set ico dates function setDateMainStart(uint _unixts) public onlyOwner checkDateOrder { require(now < _unixts && now < dateMainStart); dateMainStart = _unixts; emit IcoDateUpdated(1, _unixts); } function setDateMainEnd(uint _unixts) public onlyOwner checkDateOrder { require(now < _unixts && now < dateMainEnd); dateMainEnd = _unixts; emit IcoDateUpdated(2, _unixts); } // where are we? Passed first day or not? function isMainFirstDay() public view returns (bool) { if (now > dateMainStart && now <= dateMainStart + 1 days) return true; return false; } function isMain() public view returns (bool) { if (now > dateMainStart && now < dateMainEnd) return true; return false; } }
// ---------------------------------------------------------------------------- // // WALLIcoDates // // ----------------------------------------------------------------------------
LineComment
setDateMainStart
function setDateMainStart(uint _unixts) public onlyOwner checkDateOrder { require(now < _unixts && now < dateMainStart); dateMainStart = _unixts; emit IcoDateUpdated(1, _unixts); }
// set ico dates
LineComment
v0.4.23+commit.124ca40d
None
bzzr://cf4e1a54ac982d46286798e77068beb9d6d9b34248c3bc96ef668b7eb7004ff3
{ "func_code_index": [ 584, 801 ] }
472
WALLToken
WALLToken.sol
0x02b6361bbec213bcc34756bbd2877831d92a6c84
Solidity
WALLIcoDates
contract WALLIcoDates is Owned { uint public dateMainStart = 1619859600; // 1-MAY-2021 09:00 GMT +0 uint public dateMainEnd = 1620464400; // 8-MAY-2021 09:00 GMT +0 uint public constant DATE_LIMIT = 1620464400 + 180 days; event IcoDateUpdated(uint id, uint unixts); // check dates modifier checkDateOrder { _ ; require ( dateMainStart < dateMainEnd ) ; require ( dateMainEnd < DATE_LIMIT ) ; } constructor() public checkDateOrder() { require(now < dateMainStart); } // set ico dates function setDateMainStart(uint _unixts) public onlyOwner checkDateOrder { require(now < _unixts && now < dateMainStart); dateMainStart = _unixts; emit IcoDateUpdated(1, _unixts); } function setDateMainEnd(uint _unixts) public onlyOwner checkDateOrder { require(now < _unixts && now < dateMainEnd); dateMainEnd = _unixts; emit IcoDateUpdated(2, _unixts); } // where are we? Passed first day or not? function isMainFirstDay() public view returns (bool) { if (now > dateMainStart && now <= dateMainStart + 1 days) return true; return false; } function isMain() public view returns (bool) { if (now > dateMainStart && now < dateMainEnd) return true; return false; } }
// ---------------------------------------------------------------------------- // // WALLIcoDates // // ----------------------------------------------------------------------------
LineComment
isMainFirstDay
function isMainFirstDay() public view returns (bool) { if (now > dateMainStart && now <= dateMainStart + 1 days) return true; return false; }
// where are we? Passed first day or not?
LineComment
v0.4.23+commit.124ca40d
None
bzzr://cf4e1a54ac982d46286798e77068beb9d6d9b34248c3bc96ef668b7eb7004ff3
{ "func_code_index": [ 1067, 1236 ] }
473
WALLToken
WALLToken.sol
0x02b6361bbec213bcc34756bbd2877831d92a6c84
Solidity
WALLToken
contract WALLToken is ERC20Token, Wallet, LockSlots, WALLIcoDates { // Utility variable uint constant E18 = 10**18; // Basic token data string public constant name = "Wall Street Decentral Token"; string public constant symbol = "WALL"; uint8 public constant decimals = 18; // Token number of possible tokens in existance 3333333333 uint public constant MAX_TOTAL_TOKEN_SUPPLY = 3333333333 * E18; // ICO parameters // Opening ETH Rate: USD$1827.28 // Therefore, 1 ETH = 45682 WALL uint public tokensPerEth = 45682; // USD$2,000,000/1827.28 = 1094.523006 ether // 1094.523006 ether/2551 addresses = 0.429056450 ether per address for the first 24 hours // 65,999,999,988 MainNet Coins / 19.79999999838 = 3,333,333,333 Tokens Total Supply uint public constant MINIMUM_CONTRIBUTION = 0.2 ether; uint public constant MAXIMUM_FIRST_DAY_CONTRIBUTION = 0.429056450 ether; uint public constant TOKEN_MAIN_CAP = 50000000 * E18; bool public tokensTradeable; // whitelisting mapping(address => bool) public whitelist; uint public numberWhitelisted; // track main sale uint public tokensMain; mapping(address => uint) public balancesMain; uint public totalEthContributed; mapping(address => uint) public ethContributed; // tracking tokens minted uint public tokensMinted; mapping(address => uint) public balancesMinted; mapping(address => mapping(uint => uint)) public balancesMintedByType; // migration variable bool public isMigrationPhaseOpen; // Events --------------------------------------------- event UpdatedTokensPerEth(uint tokensPerEth); event Whitelisted(address indexed account, uint countWhitelisted); event TokensMinted(uint indexed mintType, address indexed account, uint tokens, uint term); event RegisterContribution(address indexed account, uint tokensIssued, uint ethContributed, uint ethReturned); event TokenExchangeRequested(address indexed account, uint tokens); // Basic Functions ------------------------------------ constructor() public {} function () public payable { buyTokens(); } // Information functions function availableToMint() public view returns (uint) { return MAX_TOTAL_TOKEN_SUPPLY.sub(TOKEN_MAIN_CAP).sub(tokensMinted); } function firstDayTokenLimit() public view returns (uint) { return ethToTokens(MAXIMUM_FIRST_DAY_CONTRIBUTION); } function ethToTokens(uint _eth) public view returns (uint tokens) { tokens = _eth.mul(tokensPerEth); } function tokensToEth(uint _tokens) public view returns (uint eth) { eth = _tokens / tokensPerEth; } // Admin functions function addToWhitelist(address _account) public onlyAdmin { pWhitelist(_account); } function addToWhitelistMultiple(address[] _addresses) public onlyAdmin { for (uint i; i < _addresses.length; i++) { pWhitelist(_addresses[i]); } } function pWhitelist(address _account) internal { if (whitelist[_account]) return; whitelist[_account] = true; numberWhitelisted = numberWhitelisted.add(1); emit Whitelisted(_account, numberWhitelisted); } // Owner functions ------------------------------------ function updateTokensPerEth(uint _tokens_per_eth) public onlyOwner { require(now < dateMainStart); tokensPerEth = _tokens_per_eth; emit UpdatedTokensPerEth(tokensPerEth); } // Only owner can make tokens tradable at any time, or if the date is // greater than the end of the mainsale date plus 20 weeks, allow // any caller to make tokensTradeable. function makeTradeable() public { require(msg.sender == owner || now > dateMainEnd + 20 weeks); tokensTradeable = true; } function openMigrationPhase() public onlyOwner { require(now > dateMainEnd); isMigrationPhaseOpen = true; } // Token minting -------------------------------------- function mintTokens(uint _mint_type, address _account, uint _tokens) public onlyOwner { pMintTokens(_mint_type, _account, _tokens, 0); } function mintTokensMultiple(uint _mint_type, address[] _accounts, uint[] _tokens) public onlyOwner { require(_accounts.length == _tokens.length); for (uint i; i < _accounts.length; i++) { pMintTokens(_mint_type, _accounts[i], _tokens[i], 0); } } function mintTokensLocked(uint _mint_type, address _account, uint _tokens, uint _term) public onlyOwner { pMintTokens(_mint_type, _account, _tokens, _term); } function mintTokensLockedMultiple(uint _mint_type, address[] _accounts, uint[] _tokens, uint[] _terms) public onlyOwner { require(_accounts.length == _tokens.length); require(_accounts.length == _terms.length); for (uint i; i < _accounts.length; i++) { pMintTokens(_mint_type, _accounts[i], _tokens[i], _terms[i]); } } function pMintTokens(uint _mint_type, address _account, uint _tokens, uint _term) private { require(whitelist[_account]); require(_account != 0x0); require(_tokens > 0); require(_tokens <= availableToMint(), "not enough tokens available to mint"); require(_term == 0 || _term > now, "either without lock term, or lock term must be in the future"); // register locked tokens (will throw if no slot is found) if (_term > 0) registerLockedTokens(_account, _tokens, _term); // update balances[_account] = balances[_account].add(_tokens); balancesMinted[_account] = balancesMinted[_account].add(_tokens); balancesMintedByType[_account][_mint_type] = balancesMintedByType[_account][_mint_type].add(_tokens); tokensMinted = tokensMinted.add(_tokens); tokensIssuedTotal = tokensIssuedTotal.add(_tokens); // log event emit Transfer(0x0, _account, _tokens); emit TokensMinted(_mint_type, _account, _tokens, _term); } // Main sale ------------------------------------------ function buyTokens() private { require(isMain()); require(msg.value >= MINIMUM_CONTRIBUTION); require(whitelist[msg.sender]); uint tokens_available = TOKEN_MAIN_CAP.sub(tokensMain); // adjust tokens_available on first day, if necessary if (isMainFirstDay()) { uint tokens_available_first_day = firstDayTokenLimit().sub(balancesMain[msg.sender]); if (tokens_available_first_day < tokens_available) { tokens_available = tokens_available_first_day; } } require (tokens_available > 0); uint tokens_requested = ethToTokens(msg.value); uint tokens_issued = tokens_requested; uint eth_contributed = msg.value; uint eth_returned; if (tokens_requested > tokens_available) { tokens_issued = tokens_available; eth_returned = tokensToEth(tokens_requested.sub(tokens_available)); eth_contributed = msg.value.sub(eth_returned); } balances[msg.sender] = balances[msg.sender].add(tokens_issued); balancesMain[msg.sender] = balancesMain[msg.sender].add(tokens_issued); tokensMain = tokensMain.add(tokens_issued); tokensIssuedTotal = tokensIssuedTotal.add(tokens_issued); ethContributed[msg.sender] = ethContributed[msg.sender].add(eth_contributed); totalEthContributed = totalEthContributed.add(eth_contributed); // ether transfers if (eth_returned > 0) msg.sender.transfer(eth_returned); wallet.transfer(eth_contributed); // log emit Transfer(0x0, msg.sender, tokens_issued); emit RegisterContribution(msg.sender, tokens_issued, eth_contributed, eth_returned); } // Token exchange / migration to new platform --------- function requestTokenExchangeMax() public { requestTokenExchange(unlockedTokensInternal(msg.sender)); } function requestTokenExchange(uint _tokens) public { require(isMigrationPhaseOpen); require(_tokens > 0 && _tokens <= unlockedTokensInternal(msg.sender)); balances[msg.sender] = balances[msg.sender].sub(_tokens); tokensIssuedTotal = tokensIssuedTotal.sub(_tokens); emit Transfer(msg.sender, 0x0, _tokens); emit TokenExchangeRequested(msg.sender, _tokens); } // ERC20 functions ------------------- /* Transfer out any accidentally sent ERC20 tokens */ function transferAnyERC20Token(address _token_address, uint _amount) public onlyOwner returns (bool success) { return ERC20Interface(_token_address).transfer(owner, _amount); } /* Override "transfer" */ function transfer(address _to, uint _amount) public returns (bool success) { require(tokensTradeable); require(_amount <= unlockedTokensInternal(msg.sender)); return super.transfer(_to, _amount); } /* Override "transferFrom" */ function transferFrom(address _from, address _to, uint _amount) public returns (bool success) { require(tokensTradeable); require(_amount <= unlockedTokensInternal(_from)); return super.transferFrom(_from, _to, _amount); } /* Multiple token transfers from one address to save gas */ function transferMultiple(address[] _addresses, uint[] _amounts) external { require(_addresses.length <= 100); require(_addresses.length == _amounts.length); // do the transfers for (uint j; j < _addresses.length; j++) { transfer(_addresses[j], _amounts[j]); } } }
// ---------------------------------------------------------------------------- // // WALL public token sale // // ----------------------------------------------------------------------------
LineComment
availableToMint
function availableToMint() public view returns (uint) { return MAX_TOTAL_TOKEN_SUPPLY.sub(TOKEN_MAIN_CAP).sub(tokensMinted); }
// Information functions
LineComment
v0.4.23+commit.124ca40d
None
bzzr://cf4e1a54ac982d46286798e77068beb9d6d9b34248c3bc96ef668b7eb7004ff3
{ "func_code_index": [ 2314, 2459 ] }
474
WALLToken
WALLToken.sol
0x02b6361bbec213bcc34756bbd2877831d92a6c84
Solidity
WALLToken
contract WALLToken is ERC20Token, Wallet, LockSlots, WALLIcoDates { // Utility variable uint constant E18 = 10**18; // Basic token data string public constant name = "Wall Street Decentral Token"; string public constant symbol = "WALL"; uint8 public constant decimals = 18; // Token number of possible tokens in existance 3333333333 uint public constant MAX_TOTAL_TOKEN_SUPPLY = 3333333333 * E18; // ICO parameters // Opening ETH Rate: USD$1827.28 // Therefore, 1 ETH = 45682 WALL uint public tokensPerEth = 45682; // USD$2,000,000/1827.28 = 1094.523006 ether // 1094.523006 ether/2551 addresses = 0.429056450 ether per address for the first 24 hours // 65,999,999,988 MainNet Coins / 19.79999999838 = 3,333,333,333 Tokens Total Supply uint public constant MINIMUM_CONTRIBUTION = 0.2 ether; uint public constant MAXIMUM_FIRST_DAY_CONTRIBUTION = 0.429056450 ether; uint public constant TOKEN_MAIN_CAP = 50000000 * E18; bool public tokensTradeable; // whitelisting mapping(address => bool) public whitelist; uint public numberWhitelisted; // track main sale uint public tokensMain; mapping(address => uint) public balancesMain; uint public totalEthContributed; mapping(address => uint) public ethContributed; // tracking tokens minted uint public tokensMinted; mapping(address => uint) public balancesMinted; mapping(address => mapping(uint => uint)) public balancesMintedByType; // migration variable bool public isMigrationPhaseOpen; // Events --------------------------------------------- event UpdatedTokensPerEth(uint tokensPerEth); event Whitelisted(address indexed account, uint countWhitelisted); event TokensMinted(uint indexed mintType, address indexed account, uint tokens, uint term); event RegisterContribution(address indexed account, uint tokensIssued, uint ethContributed, uint ethReturned); event TokenExchangeRequested(address indexed account, uint tokens); // Basic Functions ------------------------------------ constructor() public {} function () public payable { buyTokens(); } // Information functions function availableToMint() public view returns (uint) { return MAX_TOTAL_TOKEN_SUPPLY.sub(TOKEN_MAIN_CAP).sub(tokensMinted); } function firstDayTokenLimit() public view returns (uint) { return ethToTokens(MAXIMUM_FIRST_DAY_CONTRIBUTION); } function ethToTokens(uint _eth) public view returns (uint tokens) { tokens = _eth.mul(tokensPerEth); } function tokensToEth(uint _tokens) public view returns (uint eth) { eth = _tokens / tokensPerEth; } // Admin functions function addToWhitelist(address _account) public onlyAdmin { pWhitelist(_account); } function addToWhitelistMultiple(address[] _addresses) public onlyAdmin { for (uint i; i < _addresses.length; i++) { pWhitelist(_addresses[i]); } } function pWhitelist(address _account) internal { if (whitelist[_account]) return; whitelist[_account] = true; numberWhitelisted = numberWhitelisted.add(1); emit Whitelisted(_account, numberWhitelisted); } // Owner functions ------------------------------------ function updateTokensPerEth(uint _tokens_per_eth) public onlyOwner { require(now < dateMainStart); tokensPerEth = _tokens_per_eth; emit UpdatedTokensPerEth(tokensPerEth); } // Only owner can make tokens tradable at any time, or if the date is // greater than the end of the mainsale date plus 20 weeks, allow // any caller to make tokensTradeable. function makeTradeable() public { require(msg.sender == owner || now > dateMainEnd + 20 weeks); tokensTradeable = true; } function openMigrationPhase() public onlyOwner { require(now > dateMainEnd); isMigrationPhaseOpen = true; } // Token minting -------------------------------------- function mintTokens(uint _mint_type, address _account, uint _tokens) public onlyOwner { pMintTokens(_mint_type, _account, _tokens, 0); } function mintTokensMultiple(uint _mint_type, address[] _accounts, uint[] _tokens) public onlyOwner { require(_accounts.length == _tokens.length); for (uint i; i < _accounts.length; i++) { pMintTokens(_mint_type, _accounts[i], _tokens[i], 0); } } function mintTokensLocked(uint _mint_type, address _account, uint _tokens, uint _term) public onlyOwner { pMintTokens(_mint_type, _account, _tokens, _term); } function mintTokensLockedMultiple(uint _mint_type, address[] _accounts, uint[] _tokens, uint[] _terms) public onlyOwner { require(_accounts.length == _tokens.length); require(_accounts.length == _terms.length); for (uint i; i < _accounts.length; i++) { pMintTokens(_mint_type, _accounts[i], _tokens[i], _terms[i]); } } function pMintTokens(uint _mint_type, address _account, uint _tokens, uint _term) private { require(whitelist[_account]); require(_account != 0x0); require(_tokens > 0); require(_tokens <= availableToMint(), "not enough tokens available to mint"); require(_term == 0 || _term > now, "either without lock term, or lock term must be in the future"); // register locked tokens (will throw if no slot is found) if (_term > 0) registerLockedTokens(_account, _tokens, _term); // update balances[_account] = balances[_account].add(_tokens); balancesMinted[_account] = balancesMinted[_account].add(_tokens); balancesMintedByType[_account][_mint_type] = balancesMintedByType[_account][_mint_type].add(_tokens); tokensMinted = tokensMinted.add(_tokens); tokensIssuedTotal = tokensIssuedTotal.add(_tokens); // log event emit Transfer(0x0, _account, _tokens); emit TokensMinted(_mint_type, _account, _tokens, _term); } // Main sale ------------------------------------------ function buyTokens() private { require(isMain()); require(msg.value >= MINIMUM_CONTRIBUTION); require(whitelist[msg.sender]); uint tokens_available = TOKEN_MAIN_CAP.sub(tokensMain); // adjust tokens_available on first day, if necessary if (isMainFirstDay()) { uint tokens_available_first_day = firstDayTokenLimit().sub(balancesMain[msg.sender]); if (tokens_available_first_day < tokens_available) { tokens_available = tokens_available_first_day; } } require (tokens_available > 0); uint tokens_requested = ethToTokens(msg.value); uint tokens_issued = tokens_requested; uint eth_contributed = msg.value; uint eth_returned; if (tokens_requested > tokens_available) { tokens_issued = tokens_available; eth_returned = tokensToEth(tokens_requested.sub(tokens_available)); eth_contributed = msg.value.sub(eth_returned); } balances[msg.sender] = balances[msg.sender].add(tokens_issued); balancesMain[msg.sender] = balancesMain[msg.sender].add(tokens_issued); tokensMain = tokensMain.add(tokens_issued); tokensIssuedTotal = tokensIssuedTotal.add(tokens_issued); ethContributed[msg.sender] = ethContributed[msg.sender].add(eth_contributed); totalEthContributed = totalEthContributed.add(eth_contributed); // ether transfers if (eth_returned > 0) msg.sender.transfer(eth_returned); wallet.transfer(eth_contributed); // log emit Transfer(0x0, msg.sender, tokens_issued); emit RegisterContribution(msg.sender, tokens_issued, eth_contributed, eth_returned); } // Token exchange / migration to new platform --------- function requestTokenExchangeMax() public { requestTokenExchange(unlockedTokensInternal(msg.sender)); } function requestTokenExchange(uint _tokens) public { require(isMigrationPhaseOpen); require(_tokens > 0 && _tokens <= unlockedTokensInternal(msg.sender)); balances[msg.sender] = balances[msg.sender].sub(_tokens); tokensIssuedTotal = tokensIssuedTotal.sub(_tokens); emit Transfer(msg.sender, 0x0, _tokens); emit TokenExchangeRequested(msg.sender, _tokens); } // ERC20 functions ------------------- /* Transfer out any accidentally sent ERC20 tokens */ function transferAnyERC20Token(address _token_address, uint _amount) public onlyOwner returns (bool success) { return ERC20Interface(_token_address).transfer(owner, _amount); } /* Override "transfer" */ function transfer(address _to, uint _amount) public returns (bool success) { require(tokensTradeable); require(_amount <= unlockedTokensInternal(msg.sender)); return super.transfer(_to, _amount); } /* Override "transferFrom" */ function transferFrom(address _from, address _to, uint _amount) public returns (bool success) { require(tokensTradeable); require(_amount <= unlockedTokensInternal(_from)); return super.transferFrom(_from, _to, _amount); } /* Multiple token transfers from one address to save gas */ function transferMultiple(address[] _addresses, uint[] _amounts) external { require(_addresses.length <= 100); require(_addresses.length == _amounts.length); // do the transfers for (uint j; j < _addresses.length; j++) { transfer(_addresses[j], _amounts[j]); } } }
// ---------------------------------------------------------------------------- // // WALL public token sale // // ----------------------------------------------------------------------------
LineComment
addToWhitelist
function addToWhitelist(address _account) public onlyAdmin { pWhitelist(_account); }
// Admin functions
LineComment
v0.4.23+commit.124ca40d
None
bzzr://cf4e1a54ac982d46286798e77068beb9d6d9b34248c3bc96ef668b7eb7004ff3
{ "func_code_index": [ 2867, 2970 ] }
475
WALLToken
WALLToken.sol
0x02b6361bbec213bcc34756bbd2877831d92a6c84
Solidity
WALLToken
contract WALLToken is ERC20Token, Wallet, LockSlots, WALLIcoDates { // Utility variable uint constant E18 = 10**18; // Basic token data string public constant name = "Wall Street Decentral Token"; string public constant symbol = "WALL"; uint8 public constant decimals = 18; // Token number of possible tokens in existance 3333333333 uint public constant MAX_TOTAL_TOKEN_SUPPLY = 3333333333 * E18; // ICO parameters // Opening ETH Rate: USD$1827.28 // Therefore, 1 ETH = 45682 WALL uint public tokensPerEth = 45682; // USD$2,000,000/1827.28 = 1094.523006 ether // 1094.523006 ether/2551 addresses = 0.429056450 ether per address for the first 24 hours // 65,999,999,988 MainNet Coins / 19.79999999838 = 3,333,333,333 Tokens Total Supply uint public constant MINIMUM_CONTRIBUTION = 0.2 ether; uint public constant MAXIMUM_FIRST_DAY_CONTRIBUTION = 0.429056450 ether; uint public constant TOKEN_MAIN_CAP = 50000000 * E18; bool public tokensTradeable; // whitelisting mapping(address => bool) public whitelist; uint public numberWhitelisted; // track main sale uint public tokensMain; mapping(address => uint) public balancesMain; uint public totalEthContributed; mapping(address => uint) public ethContributed; // tracking tokens minted uint public tokensMinted; mapping(address => uint) public balancesMinted; mapping(address => mapping(uint => uint)) public balancesMintedByType; // migration variable bool public isMigrationPhaseOpen; // Events --------------------------------------------- event UpdatedTokensPerEth(uint tokensPerEth); event Whitelisted(address indexed account, uint countWhitelisted); event TokensMinted(uint indexed mintType, address indexed account, uint tokens, uint term); event RegisterContribution(address indexed account, uint tokensIssued, uint ethContributed, uint ethReturned); event TokenExchangeRequested(address indexed account, uint tokens); // Basic Functions ------------------------------------ constructor() public {} function () public payable { buyTokens(); } // Information functions function availableToMint() public view returns (uint) { return MAX_TOTAL_TOKEN_SUPPLY.sub(TOKEN_MAIN_CAP).sub(tokensMinted); } function firstDayTokenLimit() public view returns (uint) { return ethToTokens(MAXIMUM_FIRST_DAY_CONTRIBUTION); } function ethToTokens(uint _eth) public view returns (uint tokens) { tokens = _eth.mul(tokensPerEth); } function tokensToEth(uint _tokens) public view returns (uint eth) { eth = _tokens / tokensPerEth; } // Admin functions function addToWhitelist(address _account) public onlyAdmin { pWhitelist(_account); } function addToWhitelistMultiple(address[] _addresses) public onlyAdmin { for (uint i; i < _addresses.length; i++) { pWhitelist(_addresses[i]); } } function pWhitelist(address _account) internal { if (whitelist[_account]) return; whitelist[_account] = true; numberWhitelisted = numberWhitelisted.add(1); emit Whitelisted(_account, numberWhitelisted); } // Owner functions ------------------------------------ function updateTokensPerEth(uint _tokens_per_eth) public onlyOwner { require(now < dateMainStart); tokensPerEth = _tokens_per_eth; emit UpdatedTokensPerEth(tokensPerEth); } // Only owner can make tokens tradable at any time, or if the date is // greater than the end of the mainsale date plus 20 weeks, allow // any caller to make tokensTradeable. function makeTradeable() public { require(msg.sender == owner || now > dateMainEnd + 20 weeks); tokensTradeable = true; } function openMigrationPhase() public onlyOwner { require(now > dateMainEnd); isMigrationPhaseOpen = true; } // Token minting -------------------------------------- function mintTokens(uint _mint_type, address _account, uint _tokens) public onlyOwner { pMintTokens(_mint_type, _account, _tokens, 0); } function mintTokensMultiple(uint _mint_type, address[] _accounts, uint[] _tokens) public onlyOwner { require(_accounts.length == _tokens.length); for (uint i; i < _accounts.length; i++) { pMintTokens(_mint_type, _accounts[i], _tokens[i], 0); } } function mintTokensLocked(uint _mint_type, address _account, uint _tokens, uint _term) public onlyOwner { pMintTokens(_mint_type, _account, _tokens, _term); } function mintTokensLockedMultiple(uint _mint_type, address[] _accounts, uint[] _tokens, uint[] _terms) public onlyOwner { require(_accounts.length == _tokens.length); require(_accounts.length == _terms.length); for (uint i; i < _accounts.length; i++) { pMintTokens(_mint_type, _accounts[i], _tokens[i], _terms[i]); } } function pMintTokens(uint _mint_type, address _account, uint _tokens, uint _term) private { require(whitelist[_account]); require(_account != 0x0); require(_tokens > 0); require(_tokens <= availableToMint(), "not enough tokens available to mint"); require(_term == 0 || _term > now, "either without lock term, or lock term must be in the future"); // register locked tokens (will throw if no slot is found) if (_term > 0) registerLockedTokens(_account, _tokens, _term); // update balances[_account] = balances[_account].add(_tokens); balancesMinted[_account] = balancesMinted[_account].add(_tokens); balancesMintedByType[_account][_mint_type] = balancesMintedByType[_account][_mint_type].add(_tokens); tokensMinted = tokensMinted.add(_tokens); tokensIssuedTotal = tokensIssuedTotal.add(_tokens); // log event emit Transfer(0x0, _account, _tokens); emit TokensMinted(_mint_type, _account, _tokens, _term); } // Main sale ------------------------------------------ function buyTokens() private { require(isMain()); require(msg.value >= MINIMUM_CONTRIBUTION); require(whitelist[msg.sender]); uint tokens_available = TOKEN_MAIN_CAP.sub(tokensMain); // adjust tokens_available on first day, if necessary if (isMainFirstDay()) { uint tokens_available_first_day = firstDayTokenLimit().sub(balancesMain[msg.sender]); if (tokens_available_first_day < tokens_available) { tokens_available = tokens_available_first_day; } } require (tokens_available > 0); uint tokens_requested = ethToTokens(msg.value); uint tokens_issued = tokens_requested; uint eth_contributed = msg.value; uint eth_returned; if (tokens_requested > tokens_available) { tokens_issued = tokens_available; eth_returned = tokensToEth(tokens_requested.sub(tokens_available)); eth_contributed = msg.value.sub(eth_returned); } balances[msg.sender] = balances[msg.sender].add(tokens_issued); balancesMain[msg.sender] = balancesMain[msg.sender].add(tokens_issued); tokensMain = tokensMain.add(tokens_issued); tokensIssuedTotal = tokensIssuedTotal.add(tokens_issued); ethContributed[msg.sender] = ethContributed[msg.sender].add(eth_contributed); totalEthContributed = totalEthContributed.add(eth_contributed); // ether transfers if (eth_returned > 0) msg.sender.transfer(eth_returned); wallet.transfer(eth_contributed); // log emit Transfer(0x0, msg.sender, tokens_issued); emit RegisterContribution(msg.sender, tokens_issued, eth_contributed, eth_returned); } // Token exchange / migration to new platform --------- function requestTokenExchangeMax() public { requestTokenExchange(unlockedTokensInternal(msg.sender)); } function requestTokenExchange(uint _tokens) public { require(isMigrationPhaseOpen); require(_tokens > 0 && _tokens <= unlockedTokensInternal(msg.sender)); balances[msg.sender] = balances[msg.sender].sub(_tokens); tokensIssuedTotal = tokensIssuedTotal.sub(_tokens); emit Transfer(msg.sender, 0x0, _tokens); emit TokenExchangeRequested(msg.sender, _tokens); } // ERC20 functions ------------------- /* Transfer out any accidentally sent ERC20 tokens */ function transferAnyERC20Token(address _token_address, uint _amount) public onlyOwner returns (bool success) { return ERC20Interface(_token_address).transfer(owner, _amount); } /* Override "transfer" */ function transfer(address _to, uint _amount) public returns (bool success) { require(tokensTradeable); require(_amount <= unlockedTokensInternal(msg.sender)); return super.transfer(_to, _amount); } /* Override "transferFrom" */ function transferFrom(address _from, address _to, uint _amount) public returns (bool success) { require(tokensTradeable); require(_amount <= unlockedTokensInternal(_from)); return super.transferFrom(_from, _to, _amount); } /* Multiple token transfers from one address to save gas */ function transferMultiple(address[] _addresses, uint[] _amounts) external { require(_addresses.length <= 100); require(_addresses.length == _amounts.length); // do the transfers for (uint j; j < _addresses.length; j++) { transfer(_addresses[j], _amounts[j]); } } }
// ---------------------------------------------------------------------------- // // WALL public token sale // // ----------------------------------------------------------------------------
LineComment
updateTokensPerEth
function updateTokensPerEth(uint _tokens_per_eth) public onlyOwner { require(now < dateMainStart); tokensPerEth = _tokens_per_eth; emit UpdatedTokensPerEth(tokensPerEth); }
// Owner functions ------------------------------------
LineComment
v0.4.23+commit.124ca40d
None
bzzr://cf4e1a54ac982d46286798e77068beb9d6d9b34248c3bc96ef668b7eb7004ff3
{ "func_code_index": [ 3479, 3688 ] }
476
WALLToken
WALLToken.sol
0x02b6361bbec213bcc34756bbd2877831d92a6c84
Solidity
WALLToken
contract WALLToken is ERC20Token, Wallet, LockSlots, WALLIcoDates { // Utility variable uint constant E18 = 10**18; // Basic token data string public constant name = "Wall Street Decentral Token"; string public constant symbol = "WALL"; uint8 public constant decimals = 18; // Token number of possible tokens in existance 3333333333 uint public constant MAX_TOTAL_TOKEN_SUPPLY = 3333333333 * E18; // ICO parameters // Opening ETH Rate: USD$1827.28 // Therefore, 1 ETH = 45682 WALL uint public tokensPerEth = 45682; // USD$2,000,000/1827.28 = 1094.523006 ether // 1094.523006 ether/2551 addresses = 0.429056450 ether per address for the first 24 hours // 65,999,999,988 MainNet Coins / 19.79999999838 = 3,333,333,333 Tokens Total Supply uint public constant MINIMUM_CONTRIBUTION = 0.2 ether; uint public constant MAXIMUM_FIRST_DAY_CONTRIBUTION = 0.429056450 ether; uint public constant TOKEN_MAIN_CAP = 50000000 * E18; bool public tokensTradeable; // whitelisting mapping(address => bool) public whitelist; uint public numberWhitelisted; // track main sale uint public tokensMain; mapping(address => uint) public balancesMain; uint public totalEthContributed; mapping(address => uint) public ethContributed; // tracking tokens minted uint public tokensMinted; mapping(address => uint) public balancesMinted; mapping(address => mapping(uint => uint)) public balancesMintedByType; // migration variable bool public isMigrationPhaseOpen; // Events --------------------------------------------- event UpdatedTokensPerEth(uint tokensPerEth); event Whitelisted(address indexed account, uint countWhitelisted); event TokensMinted(uint indexed mintType, address indexed account, uint tokens, uint term); event RegisterContribution(address indexed account, uint tokensIssued, uint ethContributed, uint ethReturned); event TokenExchangeRequested(address indexed account, uint tokens); // Basic Functions ------------------------------------ constructor() public {} function () public payable { buyTokens(); } // Information functions function availableToMint() public view returns (uint) { return MAX_TOTAL_TOKEN_SUPPLY.sub(TOKEN_MAIN_CAP).sub(tokensMinted); } function firstDayTokenLimit() public view returns (uint) { return ethToTokens(MAXIMUM_FIRST_DAY_CONTRIBUTION); } function ethToTokens(uint _eth) public view returns (uint tokens) { tokens = _eth.mul(tokensPerEth); } function tokensToEth(uint _tokens) public view returns (uint eth) { eth = _tokens / tokensPerEth; } // Admin functions function addToWhitelist(address _account) public onlyAdmin { pWhitelist(_account); } function addToWhitelistMultiple(address[] _addresses) public onlyAdmin { for (uint i; i < _addresses.length; i++) { pWhitelist(_addresses[i]); } } function pWhitelist(address _account) internal { if (whitelist[_account]) return; whitelist[_account] = true; numberWhitelisted = numberWhitelisted.add(1); emit Whitelisted(_account, numberWhitelisted); } // Owner functions ------------------------------------ function updateTokensPerEth(uint _tokens_per_eth) public onlyOwner { require(now < dateMainStart); tokensPerEth = _tokens_per_eth; emit UpdatedTokensPerEth(tokensPerEth); } // Only owner can make tokens tradable at any time, or if the date is // greater than the end of the mainsale date plus 20 weeks, allow // any caller to make tokensTradeable. function makeTradeable() public { require(msg.sender == owner || now > dateMainEnd + 20 weeks); tokensTradeable = true; } function openMigrationPhase() public onlyOwner { require(now > dateMainEnd); isMigrationPhaseOpen = true; } // Token minting -------------------------------------- function mintTokens(uint _mint_type, address _account, uint _tokens) public onlyOwner { pMintTokens(_mint_type, _account, _tokens, 0); } function mintTokensMultiple(uint _mint_type, address[] _accounts, uint[] _tokens) public onlyOwner { require(_accounts.length == _tokens.length); for (uint i; i < _accounts.length; i++) { pMintTokens(_mint_type, _accounts[i], _tokens[i], 0); } } function mintTokensLocked(uint _mint_type, address _account, uint _tokens, uint _term) public onlyOwner { pMintTokens(_mint_type, _account, _tokens, _term); } function mintTokensLockedMultiple(uint _mint_type, address[] _accounts, uint[] _tokens, uint[] _terms) public onlyOwner { require(_accounts.length == _tokens.length); require(_accounts.length == _terms.length); for (uint i; i < _accounts.length; i++) { pMintTokens(_mint_type, _accounts[i], _tokens[i], _terms[i]); } } function pMintTokens(uint _mint_type, address _account, uint _tokens, uint _term) private { require(whitelist[_account]); require(_account != 0x0); require(_tokens > 0); require(_tokens <= availableToMint(), "not enough tokens available to mint"); require(_term == 0 || _term > now, "either without lock term, or lock term must be in the future"); // register locked tokens (will throw if no slot is found) if (_term > 0) registerLockedTokens(_account, _tokens, _term); // update balances[_account] = balances[_account].add(_tokens); balancesMinted[_account] = balancesMinted[_account].add(_tokens); balancesMintedByType[_account][_mint_type] = balancesMintedByType[_account][_mint_type].add(_tokens); tokensMinted = tokensMinted.add(_tokens); tokensIssuedTotal = tokensIssuedTotal.add(_tokens); // log event emit Transfer(0x0, _account, _tokens); emit TokensMinted(_mint_type, _account, _tokens, _term); } // Main sale ------------------------------------------ function buyTokens() private { require(isMain()); require(msg.value >= MINIMUM_CONTRIBUTION); require(whitelist[msg.sender]); uint tokens_available = TOKEN_MAIN_CAP.sub(tokensMain); // adjust tokens_available on first day, if necessary if (isMainFirstDay()) { uint tokens_available_first_day = firstDayTokenLimit().sub(balancesMain[msg.sender]); if (tokens_available_first_day < tokens_available) { tokens_available = tokens_available_first_day; } } require (tokens_available > 0); uint tokens_requested = ethToTokens(msg.value); uint tokens_issued = tokens_requested; uint eth_contributed = msg.value; uint eth_returned; if (tokens_requested > tokens_available) { tokens_issued = tokens_available; eth_returned = tokensToEth(tokens_requested.sub(tokens_available)); eth_contributed = msg.value.sub(eth_returned); } balances[msg.sender] = balances[msg.sender].add(tokens_issued); balancesMain[msg.sender] = balancesMain[msg.sender].add(tokens_issued); tokensMain = tokensMain.add(tokens_issued); tokensIssuedTotal = tokensIssuedTotal.add(tokens_issued); ethContributed[msg.sender] = ethContributed[msg.sender].add(eth_contributed); totalEthContributed = totalEthContributed.add(eth_contributed); // ether transfers if (eth_returned > 0) msg.sender.transfer(eth_returned); wallet.transfer(eth_contributed); // log emit Transfer(0x0, msg.sender, tokens_issued); emit RegisterContribution(msg.sender, tokens_issued, eth_contributed, eth_returned); } // Token exchange / migration to new platform --------- function requestTokenExchangeMax() public { requestTokenExchange(unlockedTokensInternal(msg.sender)); } function requestTokenExchange(uint _tokens) public { require(isMigrationPhaseOpen); require(_tokens > 0 && _tokens <= unlockedTokensInternal(msg.sender)); balances[msg.sender] = balances[msg.sender].sub(_tokens); tokensIssuedTotal = tokensIssuedTotal.sub(_tokens); emit Transfer(msg.sender, 0x0, _tokens); emit TokenExchangeRequested(msg.sender, _tokens); } // ERC20 functions ------------------- /* Transfer out any accidentally sent ERC20 tokens */ function transferAnyERC20Token(address _token_address, uint _amount) public onlyOwner returns (bool success) { return ERC20Interface(_token_address).transfer(owner, _amount); } /* Override "transfer" */ function transfer(address _to, uint _amount) public returns (bool success) { require(tokensTradeable); require(_amount <= unlockedTokensInternal(msg.sender)); return super.transfer(_to, _amount); } /* Override "transferFrom" */ function transferFrom(address _from, address _to, uint _amount) public returns (bool success) { require(tokensTradeable); require(_amount <= unlockedTokensInternal(_from)); return super.transferFrom(_from, _to, _amount); } /* Multiple token transfers from one address to save gas */ function transferMultiple(address[] _addresses, uint[] _amounts) external { require(_addresses.length <= 100); require(_addresses.length == _amounts.length); // do the transfers for (uint j; j < _addresses.length; j++) { transfer(_addresses[j], _amounts[j]); } } }
// ---------------------------------------------------------------------------- // // WALL public token sale // // ----------------------------------------------------------------------------
LineComment
makeTradeable
function makeTradeable() public { require(msg.sender == owner || now > dateMainEnd + 20 weeks); tokensTradeable = true; }
// Only owner can make tokens tradable at any time, or if the date is // greater than the end of the mainsale date plus 20 weeks, allow // any caller to make tokensTradeable.
LineComment
v0.4.23+commit.124ca40d
None
bzzr://cf4e1a54ac982d46286798e77068beb9d6d9b34248c3bc96ef668b7eb7004ff3
{ "func_code_index": [ 3883, 4032 ] }
477
WALLToken
WALLToken.sol
0x02b6361bbec213bcc34756bbd2877831d92a6c84
Solidity
WALLToken
contract WALLToken is ERC20Token, Wallet, LockSlots, WALLIcoDates { // Utility variable uint constant E18 = 10**18; // Basic token data string public constant name = "Wall Street Decentral Token"; string public constant symbol = "WALL"; uint8 public constant decimals = 18; // Token number of possible tokens in existance 3333333333 uint public constant MAX_TOTAL_TOKEN_SUPPLY = 3333333333 * E18; // ICO parameters // Opening ETH Rate: USD$1827.28 // Therefore, 1 ETH = 45682 WALL uint public tokensPerEth = 45682; // USD$2,000,000/1827.28 = 1094.523006 ether // 1094.523006 ether/2551 addresses = 0.429056450 ether per address for the first 24 hours // 65,999,999,988 MainNet Coins / 19.79999999838 = 3,333,333,333 Tokens Total Supply uint public constant MINIMUM_CONTRIBUTION = 0.2 ether; uint public constant MAXIMUM_FIRST_DAY_CONTRIBUTION = 0.429056450 ether; uint public constant TOKEN_MAIN_CAP = 50000000 * E18; bool public tokensTradeable; // whitelisting mapping(address => bool) public whitelist; uint public numberWhitelisted; // track main sale uint public tokensMain; mapping(address => uint) public balancesMain; uint public totalEthContributed; mapping(address => uint) public ethContributed; // tracking tokens minted uint public tokensMinted; mapping(address => uint) public balancesMinted; mapping(address => mapping(uint => uint)) public balancesMintedByType; // migration variable bool public isMigrationPhaseOpen; // Events --------------------------------------------- event UpdatedTokensPerEth(uint tokensPerEth); event Whitelisted(address indexed account, uint countWhitelisted); event TokensMinted(uint indexed mintType, address indexed account, uint tokens, uint term); event RegisterContribution(address indexed account, uint tokensIssued, uint ethContributed, uint ethReturned); event TokenExchangeRequested(address indexed account, uint tokens); // Basic Functions ------------------------------------ constructor() public {} function () public payable { buyTokens(); } // Information functions function availableToMint() public view returns (uint) { return MAX_TOTAL_TOKEN_SUPPLY.sub(TOKEN_MAIN_CAP).sub(tokensMinted); } function firstDayTokenLimit() public view returns (uint) { return ethToTokens(MAXIMUM_FIRST_DAY_CONTRIBUTION); } function ethToTokens(uint _eth) public view returns (uint tokens) { tokens = _eth.mul(tokensPerEth); } function tokensToEth(uint _tokens) public view returns (uint eth) { eth = _tokens / tokensPerEth; } // Admin functions function addToWhitelist(address _account) public onlyAdmin { pWhitelist(_account); } function addToWhitelistMultiple(address[] _addresses) public onlyAdmin { for (uint i; i < _addresses.length; i++) { pWhitelist(_addresses[i]); } } function pWhitelist(address _account) internal { if (whitelist[_account]) return; whitelist[_account] = true; numberWhitelisted = numberWhitelisted.add(1); emit Whitelisted(_account, numberWhitelisted); } // Owner functions ------------------------------------ function updateTokensPerEth(uint _tokens_per_eth) public onlyOwner { require(now < dateMainStart); tokensPerEth = _tokens_per_eth; emit UpdatedTokensPerEth(tokensPerEth); } // Only owner can make tokens tradable at any time, or if the date is // greater than the end of the mainsale date plus 20 weeks, allow // any caller to make tokensTradeable. function makeTradeable() public { require(msg.sender == owner || now > dateMainEnd + 20 weeks); tokensTradeable = true; } function openMigrationPhase() public onlyOwner { require(now > dateMainEnd); isMigrationPhaseOpen = true; } // Token minting -------------------------------------- function mintTokens(uint _mint_type, address _account, uint _tokens) public onlyOwner { pMintTokens(_mint_type, _account, _tokens, 0); } function mintTokensMultiple(uint _mint_type, address[] _accounts, uint[] _tokens) public onlyOwner { require(_accounts.length == _tokens.length); for (uint i; i < _accounts.length; i++) { pMintTokens(_mint_type, _accounts[i], _tokens[i], 0); } } function mintTokensLocked(uint _mint_type, address _account, uint _tokens, uint _term) public onlyOwner { pMintTokens(_mint_type, _account, _tokens, _term); } function mintTokensLockedMultiple(uint _mint_type, address[] _accounts, uint[] _tokens, uint[] _terms) public onlyOwner { require(_accounts.length == _tokens.length); require(_accounts.length == _terms.length); for (uint i; i < _accounts.length; i++) { pMintTokens(_mint_type, _accounts[i], _tokens[i], _terms[i]); } } function pMintTokens(uint _mint_type, address _account, uint _tokens, uint _term) private { require(whitelist[_account]); require(_account != 0x0); require(_tokens > 0); require(_tokens <= availableToMint(), "not enough tokens available to mint"); require(_term == 0 || _term > now, "either without lock term, or lock term must be in the future"); // register locked tokens (will throw if no slot is found) if (_term > 0) registerLockedTokens(_account, _tokens, _term); // update balances[_account] = balances[_account].add(_tokens); balancesMinted[_account] = balancesMinted[_account].add(_tokens); balancesMintedByType[_account][_mint_type] = balancesMintedByType[_account][_mint_type].add(_tokens); tokensMinted = tokensMinted.add(_tokens); tokensIssuedTotal = tokensIssuedTotal.add(_tokens); // log event emit Transfer(0x0, _account, _tokens); emit TokensMinted(_mint_type, _account, _tokens, _term); } // Main sale ------------------------------------------ function buyTokens() private { require(isMain()); require(msg.value >= MINIMUM_CONTRIBUTION); require(whitelist[msg.sender]); uint tokens_available = TOKEN_MAIN_CAP.sub(tokensMain); // adjust tokens_available on first day, if necessary if (isMainFirstDay()) { uint tokens_available_first_day = firstDayTokenLimit().sub(balancesMain[msg.sender]); if (tokens_available_first_day < tokens_available) { tokens_available = tokens_available_first_day; } } require (tokens_available > 0); uint tokens_requested = ethToTokens(msg.value); uint tokens_issued = tokens_requested; uint eth_contributed = msg.value; uint eth_returned; if (tokens_requested > tokens_available) { tokens_issued = tokens_available; eth_returned = tokensToEth(tokens_requested.sub(tokens_available)); eth_contributed = msg.value.sub(eth_returned); } balances[msg.sender] = balances[msg.sender].add(tokens_issued); balancesMain[msg.sender] = balancesMain[msg.sender].add(tokens_issued); tokensMain = tokensMain.add(tokens_issued); tokensIssuedTotal = tokensIssuedTotal.add(tokens_issued); ethContributed[msg.sender] = ethContributed[msg.sender].add(eth_contributed); totalEthContributed = totalEthContributed.add(eth_contributed); // ether transfers if (eth_returned > 0) msg.sender.transfer(eth_returned); wallet.transfer(eth_contributed); // log emit Transfer(0x0, msg.sender, tokens_issued); emit RegisterContribution(msg.sender, tokens_issued, eth_contributed, eth_returned); } // Token exchange / migration to new platform --------- function requestTokenExchangeMax() public { requestTokenExchange(unlockedTokensInternal(msg.sender)); } function requestTokenExchange(uint _tokens) public { require(isMigrationPhaseOpen); require(_tokens > 0 && _tokens <= unlockedTokensInternal(msg.sender)); balances[msg.sender] = balances[msg.sender].sub(_tokens); tokensIssuedTotal = tokensIssuedTotal.sub(_tokens); emit Transfer(msg.sender, 0x0, _tokens); emit TokenExchangeRequested(msg.sender, _tokens); } // ERC20 functions ------------------- /* Transfer out any accidentally sent ERC20 tokens */ function transferAnyERC20Token(address _token_address, uint _amount) public onlyOwner returns (bool success) { return ERC20Interface(_token_address).transfer(owner, _amount); } /* Override "transfer" */ function transfer(address _to, uint _amount) public returns (bool success) { require(tokensTradeable); require(_amount <= unlockedTokensInternal(msg.sender)); return super.transfer(_to, _amount); } /* Override "transferFrom" */ function transferFrom(address _from, address _to, uint _amount) public returns (bool success) { require(tokensTradeable); require(_amount <= unlockedTokensInternal(_from)); return super.transferFrom(_from, _to, _amount); } /* Multiple token transfers from one address to save gas */ function transferMultiple(address[] _addresses, uint[] _amounts) external { require(_addresses.length <= 100); require(_addresses.length == _amounts.length); // do the transfers for (uint j; j < _addresses.length; j++) { transfer(_addresses[j], _amounts[j]); } } }
// ---------------------------------------------------------------------------- // // WALL public token sale // // ----------------------------------------------------------------------------
LineComment
mintTokens
function mintTokens(uint _mint_type, address _account, uint _tokens) public onlyOwner { pMintTokens(_mint_type, _account, _tokens, 0); }
// Token minting --------------------------------------
LineComment
v0.4.23+commit.124ca40d
None
bzzr://cf4e1a54ac982d46286798e77068beb9d6d9b34248c3bc96ef668b7eb7004ff3
{ "func_code_index": [ 4236, 4391 ] }
478
WALLToken
WALLToken.sol
0x02b6361bbec213bcc34756bbd2877831d92a6c84
Solidity
WALLToken
contract WALLToken is ERC20Token, Wallet, LockSlots, WALLIcoDates { // Utility variable uint constant E18 = 10**18; // Basic token data string public constant name = "Wall Street Decentral Token"; string public constant symbol = "WALL"; uint8 public constant decimals = 18; // Token number of possible tokens in existance 3333333333 uint public constant MAX_TOTAL_TOKEN_SUPPLY = 3333333333 * E18; // ICO parameters // Opening ETH Rate: USD$1827.28 // Therefore, 1 ETH = 45682 WALL uint public tokensPerEth = 45682; // USD$2,000,000/1827.28 = 1094.523006 ether // 1094.523006 ether/2551 addresses = 0.429056450 ether per address for the first 24 hours // 65,999,999,988 MainNet Coins / 19.79999999838 = 3,333,333,333 Tokens Total Supply uint public constant MINIMUM_CONTRIBUTION = 0.2 ether; uint public constant MAXIMUM_FIRST_DAY_CONTRIBUTION = 0.429056450 ether; uint public constant TOKEN_MAIN_CAP = 50000000 * E18; bool public tokensTradeable; // whitelisting mapping(address => bool) public whitelist; uint public numberWhitelisted; // track main sale uint public tokensMain; mapping(address => uint) public balancesMain; uint public totalEthContributed; mapping(address => uint) public ethContributed; // tracking tokens minted uint public tokensMinted; mapping(address => uint) public balancesMinted; mapping(address => mapping(uint => uint)) public balancesMintedByType; // migration variable bool public isMigrationPhaseOpen; // Events --------------------------------------------- event UpdatedTokensPerEth(uint tokensPerEth); event Whitelisted(address indexed account, uint countWhitelisted); event TokensMinted(uint indexed mintType, address indexed account, uint tokens, uint term); event RegisterContribution(address indexed account, uint tokensIssued, uint ethContributed, uint ethReturned); event TokenExchangeRequested(address indexed account, uint tokens); // Basic Functions ------------------------------------ constructor() public {} function () public payable { buyTokens(); } // Information functions function availableToMint() public view returns (uint) { return MAX_TOTAL_TOKEN_SUPPLY.sub(TOKEN_MAIN_CAP).sub(tokensMinted); } function firstDayTokenLimit() public view returns (uint) { return ethToTokens(MAXIMUM_FIRST_DAY_CONTRIBUTION); } function ethToTokens(uint _eth) public view returns (uint tokens) { tokens = _eth.mul(tokensPerEth); } function tokensToEth(uint _tokens) public view returns (uint eth) { eth = _tokens / tokensPerEth; } // Admin functions function addToWhitelist(address _account) public onlyAdmin { pWhitelist(_account); } function addToWhitelistMultiple(address[] _addresses) public onlyAdmin { for (uint i; i < _addresses.length; i++) { pWhitelist(_addresses[i]); } } function pWhitelist(address _account) internal { if (whitelist[_account]) return; whitelist[_account] = true; numberWhitelisted = numberWhitelisted.add(1); emit Whitelisted(_account, numberWhitelisted); } // Owner functions ------------------------------------ function updateTokensPerEth(uint _tokens_per_eth) public onlyOwner { require(now < dateMainStart); tokensPerEth = _tokens_per_eth; emit UpdatedTokensPerEth(tokensPerEth); } // Only owner can make tokens tradable at any time, or if the date is // greater than the end of the mainsale date plus 20 weeks, allow // any caller to make tokensTradeable. function makeTradeable() public { require(msg.sender == owner || now > dateMainEnd + 20 weeks); tokensTradeable = true; } function openMigrationPhase() public onlyOwner { require(now > dateMainEnd); isMigrationPhaseOpen = true; } // Token minting -------------------------------------- function mintTokens(uint _mint_type, address _account, uint _tokens) public onlyOwner { pMintTokens(_mint_type, _account, _tokens, 0); } function mintTokensMultiple(uint _mint_type, address[] _accounts, uint[] _tokens) public onlyOwner { require(_accounts.length == _tokens.length); for (uint i; i < _accounts.length; i++) { pMintTokens(_mint_type, _accounts[i], _tokens[i], 0); } } function mintTokensLocked(uint _mint_type, address _account, uint _tokens, uint _term) public onlyOwner { pMintTokens(_mint_type, _account, _tokens, _term); } function mintTokensLockedMultiple(uint _mint_type, address[] _accounts, uint[] _tokens, uint[] _terms) public onlyOwner { require(_accounts.length == _tokens.length); require(_accounts.length == _terms.length); for (uint i; i < _accounts.length; i++) { pMintTokens(_mint_type, _accounts[i], _tokens[i], _terms[i]); } } function pMintTokens(uint _mint_type, address _account, uint _tokens, uint _term) private { require(whitelist[_account]); require(_account != 0x0); require(_tokens > 0); require(_tokens <= availableToMint(), "not enough tokens available to mint"); require(_term == 0 || _term > now, "either without lock term, or lock term must be in the future"); // register locked tokens (will throw if no slot is found) if (_term > 0) registerLockedTokens(_account, _tokens, _term); // update balances[_account] = balances[_account].add(_tokens); balancesMinted[_account] = balancesMinted[_account].add(_tokens); balancesMintedByType[_account][_mint_type] = balancesMintedByType[_account][_mint_type].add(_tokens); tokensMinted = tokensMinted.add(_tokens); tokensIssuedTotal = tokensIssuedTotal.add(_tokens); // log event emit Transfer(0x0, _account, _tokens); emit TokensMinted(_mint_type, _account, _tokens, _term); } // Main sale ------------------------------------------ function buyTokens() private { require(isMain()); require(msg.value >= MINIMUM_CONTRIBUTION); require(whitelist[msg.sender]); uint tokens_available = TOKEN_MAIN_CAP.sub(tokensMain); // adjust tokens_available on first day, if necessary if (isMainFirstDay()) { uint tokens_available_first_day = firstDayTokenLimit().sub(balancesMain[msg.sender]); if (tokens_available_first_day < tokens_available) { tokens_available = tokens_available_first_day; } } require (tokens_available > 0); uint tokens_requested = ethToTokens(msg.value); uint tokens_issued = tokens_requested; uint eth_contributed = msg.value; uint eth_returned; if (tokens_requested > tokens_available) { tokens_issued = tokens_available; eth_returned = tokensToEth(tokens_requested.sub(tokens_available)); eth_contributed = msg.value.sub(eth_returned); } balances[msg.sender] = balances[msg.sender].add(tokens_issued); balancesMain[msg.sender] = balancesMain[msg.sender].add(tokens_issued); tokensMain = tokensMain.add(tokens_issued); tokensIssuedTotal = tokensIssuedTotal.add(tokens_issued); ethContributed[msg.sender] = ethContributed[msg.sender].add(eth_contributed); totalEthContributed = totalEthContributed.add(eth_contributed); // ether transfers if (eth_returned > 0) msg.sender.transfer(eth_returned); wallet.transfer(eth_contributed); // log emit Transfer(0x0, msg.sender, tokens_issued); emit RegisterContribution(msg.sender, tokens_issued, eth_contributed, eth_returned); } // Token exchange / migration to new platform --------- function requestTokenExchangeMax() public { requestTokenExchange(unlockedTokensInternal(msg.sender)); } function requestTokenExchange(uint _tokens) public { require(isMigrationPhaseOpen); require(_tokens > 0 && _tokens <= unlockedTokensInternal(msg.sender)); balances[msg.sender] = balances[msg.sender].sub(_tokens); tokensIssuedTotal = tokensIssuedTotal.sub(_tokens); emit Transfer(msg.sender, 0x0, _tokens); emit TokenExchangeRequested(msg.sender, _tokens); } // ERC20 functions ------------------- /* Transfer out any accidentally sent ERC20 tokens */ function transferAnyERC20Token(address _token_address, uint _amount) public onlyOwner returns (bool success) { return ERC20Interface(_token_address).transfer(owner, _amount); } /* Override "transfer" */ function transfer(address _to, uint _amount) public returns (bool success) { require(tokensTradeable); require(_amount <= unlockedTokensInternal(msg.sender)); return super.transfer(_to, _amount); } /* Override "transferFrom" */ function transferFrom(address _from, address _to, uint _amount) public returns (bool success) { require(tokensTradeable); require(_amount <= unlockedTokensInternal(_from)); return super.transferFrom(_from, _to, _amount); } /* Multiple token transfers from one address to save gas */ function transferMultiple(address[] _addresses, uint[] _amounts) external { require(_addresses.length <= 100); require(_addresses.length == _amounts.length); // do the transfers for (uint j; j < _addresses.length; j++) { transfer(_addresses[j], _amounts[j]); } } }
// ---------------------------------------------------------------------------- // // WALL public token sale // // ----------------------------------------------------------------------------
LineComment
buyTokens
function buyTokens() private { require(isMain()); require(msg.value >= MINIMUM_CONTRIBUTION); require(whitelist[msg.sender]); uint tokens_available = TOKEN_MAIN_CAP.sub(tokensMain); // adjust tokens_available on first day, if necessary if (isMainFirstDay()) { uint tokens_available_first_day = firstDayTokenLimit().sub(balancesMain[msg.sender]); if (tokens_available_first_day < tokens_available) { tokens_available = tokens_available_first_day; } } require (tokens_available > 0); uint tokens_requested = ethToTokens(msg.value); uint tokens_issued = tokens_requested; uint eth_contributed = msg.value; uint eth_returned; if (tokens_requested > tokens_available) { tokens_issued = tokens_available; eth_returned = tokensToEth(tokens_requested.sub(tokens_available)); eth_contributed = msg.value.sub(eth_returned); } balances[msg.sender] = balances[msg.sender].add(tokens_issued); balancesMain[msg.sender] = balancesMain[msg.sender].add(tokens_issued); tokensMain = tokensMain.add(tokens_issued); tokensIssuedTotal = tokensIssuedTotal.add(tokens_issued); ethContributed[msg.sender] = ethContributed[msg.sender].add(eth_contributed); totalEthContributed = totalEthContributed.add(eth_contributed); // ether transfers if (eth_returned > 0) msg.sender.transfer(eth_returned); wallet.transfer(eth_contributed); // log emit Transfer(0x0, msg.sender, tokens_issued); emit RegisterContribution(msg.sender, tokens_issued, eth_contributed, eth_returned); }
// Main sale ------------------------------------------
LineComment
v0.4.23+commit.124ca40d
None
bzzr://cf4e1a54ac982d46286798e77068beb9d6d9b34248c3bc96ef668b7eb7004ff3
{ "func_code_index": [ 6384, 8191 ] }
479
WALLToken
WALLToken.sol
0x02b6361bbec213bcc34756bbd2877831d92a6c84
Solidity
WALLToken
contract WALLToken is ERC20Token, Wallet, LockSlots, WALLIcoDates { // Utility variable uint constant E18 = 10**18; // Basic token data string public constant name = "Wall Street Decentral Token"; string public constant symbol = "WALL"; uint8 public constant decimals = 18; // Token number of possible tokens in existance 3333333333 uint public constant MAX_TOTAL_TOKEN_SUPPLY = 3333333333 * E18; // ICO parameters // Opening ETH Rate: USD$1827.28 // Therefore, 1 ETH = 45682 WALL uint public tokensPerEth = 45682; // USD$2,000,000/1827.28 = 1094.523006 ether // 1094.523006 ether/2551 addresses = 0.429056450 ether per address for the first 24 hours // 65,999,999,988 MainNet Coins / 19.79999999838 = 3,333,333,333 Tokens Total Supply uint public constant MINIMUM_CONTRIBUTION = 0.2 ether; uint public constant MAXIMUM_FIRST_DAY_CONTRIBUTION = 0.429056450 ether; uint public constant TOKEN_MAIN_CAP = 50000000 * E18; bool public tokensTradeable; // whitelisting mapping(address => bool) public whitelist; uint public numberWhitelisted; // track main sale uint public tokensMain; mapping(address => uint) public balancesMain; uint public totalEthContributed; mapping(address => uint) public ethContributed; // tracking tokens minted uint public tokensMinted; mapping(address => uint) public balancesMinted; mapping(address => mapping(uint => uint)) public balancesMintedByType; // migration variable bool public isMigrationPhaseOpen; // Events --------------------------------------------- event UpdatedTokensPerEth(uint tokensPerEth); event Whitelisted(address indexed account, uint countWhitelisted); event TokensMinted(uint indexed mintType, address indexed account, uint tokens, uint term); event RegisterContribution(address indexed account, uint tokensIssued, uint ethContributed, uint ethReturned); event TokenExchangeRequested(address indexed account, uint tokens); // Basic Functions ------------------------------------ constructor() public {} function () public payable { buyTokens(); } // Information functions function availableToMint() public view returns (uint) { return MAX_TOTAL_TOKEN_SUPPLY.sub(TOKEN_MAIN_CAP).sub(tokensMinted); } function firstDayTokenLimit() public view returns (uint) { return ethToTokens(MAXIMUM_FIRST_DAY_CONTRIBUTION); } function ethToTokens(uint _eth) public view returns (uint tokens) { tokens = _eth.mul(tokensPerEth); } function tokensToEth(uint _tokens) public view returns (uint eth) { eth = _tokens / tokensPerEth; } // Admin functions function addToWhitelist(address _account) public onlyAdmin { pWhitelist(_account); } function addToWhitelistMultiple(address[] _addresses) public onlyAdmin { for (uint i; i < _addresses.length; i++) { pWhitelist(_addresses[i]); } } function pWhitelist(address _account) internal { if (whitelist[_account]) return; whitelist[_account] = true; numberWhitelisted = numberWhitelisted.add(1); emit Whitelisted(_account, numberWhitelisted); } // Owner functions ------------------------------------ function updateTokensPerEth(uint _tokens_per_eth) public onlyOwner { require(now < dateMainStart); tokensPerEth = _tokens_per_eth; emit UpdatedTokensPerEth(tokensPerEth); } // Only owner can make tokens tradable at any time, or if the date is // greater than the end of the mainsale date plus 20 weeks, allow // any caller to make tokensTradeable. function makeTradeable() public { require(msg.sender == owner || now > dateMainEnd + 20 weeks); tokensTradeable = true; } function openMigrationPhase() public onlyOwner { require(now > dateMainEnd); isMigrationPhaseOpen = true; } // Token minting -------------------------------------- function mintTokens(uint _mint_type, address _account, uint _tokens) public onlyOwner { pMintTokens(_mint_type, _account, _tokens, 0); } function mintTokensMultiple(uint _mint_type, address[] _accounts, uint[] _tokens) public onlyOwner { require(_accounts.length == _tokens.length); for (uint i; i < _accounts.length; i++) { pMintTokens(_mint_type, _accounts[i], _tokens[i], 0); } } function mintTokensLocked(uint _mint_type, address _account, uint _tokens, uint _term) public onlyOwner { pMintTokens(_mint_type, _account, _tokens, _term); } function mintTokensLockedMultiple(uint _mint_type, address[] _accounts, uint[] _tokens, uint[] _terms) public onlyOwner { require(_accounts.length == _tokens.length); require(_accounts.length == _terms.length); for (uint i; i < _accounts.length; i++) { pMintTokens(_mint_type, _accounts[i], _tokens[i], _terms[i]); } } function pMintTokens(uint _mint_type, address _account, uint _tokens, uint _term) private { require(whitelist[_account]); require(_account != 0x0); require(_tokens > 0); require(_tokens <= availableToMint(), "not enough tokens available to mint"); require(_term == 0 || _term > now, "either without lock term, or lock term must be in the future"); // register locked tokens (will throw if no slot is found) if (_term > 0) registerLockedTokens(_account, _tokens, _term); // update balances[_account] = balances[_account].add(_tokens); balancesMinted[_account] = balancesMinted[_account].add(_tokens); balancesMintedByType[_account][_mint_type] = balancesMintedByType[_account][_mint_type].add(_tokens); tokensMinted = tokensMinted.add(_tokens); tokensIssuedTotal = tokensIssuedTotal.add(_tokens); // log event emit Transfer(0x0, _account, _tokens); emit TokensMinted(_mint_type, _account, _tokens, _term); } // Main sale ------------------------------------------ function buyTokens() private { require(isMain()); require(msg.value >= MINIMUM_CONTRIBUTION); require(whitelist[msg.sender]); uint tokens_available = TOKEN_MAIN_CAP.sub(tokensMain); // adjust tokens_available on first day, if necessary if (isMainFirstDay()) { uint tokens_available_first_day = firstDayTokenLimit().sub(balancesMain[msg.sender]); if (tokens_available_first_day < tokens_available) { tokens_available = tokens_available_first_day; } } require (tokens_available > 0); uint tokens_requested = ethToTokens(msg.value); uint tokens_issued = tokens_requested; uint eth_contributed = msg.value; uint eth_returned; if (tokens_requested > tokens_available) { tokens_issued = tokens_available; eth_returned = tokensToEth(tokens_requested.sub(tokens_available)); eth_contributed = msg.value.sub(eth_returned); } balances[msg.sender] = balances[msg.sender].add(tokens_issued); balancesMain[msg.sender] = balancesMain[msg.sender].add(tokens_issued); tokensMain = tokensMain.add(tokens_issued); tokensIssuedTotal = tokensIssuedTotal.add(tokens_issued); ethContributed[msg.sender] = ethContributed[msg.sender].add(eth_contributed); totalEthContributed = totalEthContributed.add(eth_contributed); // ether transfers if (eth_returned > 0) msg.sender.transfer(eth_returned); wallet.transfer(eth_contributed); // log emit Transfer(0x0, msg.sender, tokens_issued); emit RegisterContribution(msg.sender, tokens_issued, eth_contributed, eth_returned); } // Token exchange / migration to new platform --------- function requestTokenExchangeMax() public { requestTokenExchange(unlockedTokensInternal(msg.sender)); } function requestTokenExchange(uint _tokens) public { require(isMigrationPhaseOpen); require(_tokens > 0 && _tokens <= unlockedTokensInternal(msg.sender)); balances[msg.sender] = balances[msg.sender].sub(_tokens); tokensIssuedTotal = tokensIssuedTotal.sub(_tokens); emit Transfer(msg.sender, 0x0, _tokens); emit TokenExchangeRequested(msg.sender, _tokens); } // ERC20 functions ------------------- /* Transfer out any accidentally sent ERC20 tokens */ function transferAnyERC20Token(address _token_address, uint _amount) public onlyOwner returns (bool success) { return ERC20Interface(_token_address).transfer(owner, _amount); } /* Override "transfer" */ function transfer(address _to, uint _amount) public returns (bool success) { require(tokensTradeable); require(_amount <= unlockedTokensInternal(msg.sender)); return super.transfer(_to, _amount); } /* Override "transferFrom" */ function transferFrom(address _from, address _to, uint _amount) public returns (bool success) { require(tokensTradeable); require(_amount <= unlockedTokensInternal(_from)); return super.transferFrom(_from, _to, _amount); } /* Multiple token transfers from one address to save gas */ function transferMultiple(address[] _addresses, uint[] _amounts) external { require(_addresses.length <= 100); require(_addresses.length == _amounts.length); // do the transfers for (uint j; j < _addresses.length; j++) { transfer(_addresses[j], _amounts[j]); } } }
// ---------------------------------------------------------------------------- // // WALL public token sale // // ----------------------------------------------------------------------------
LineComment
requestTokenExchangeMax
function requestTokenExchangeMax() public { requestTokenExchange(unlockedTokensInternal(msg.sender)); }
// Token exchange / migration to new platform ---------
LineComment
v0.4.23+commit.124ca40d
None
bzzr://cf4e1a54ac982d46286798e77068beb9d6d9b34248c3bc96ef668b7eb7004ff3
{ "func_code_index": [ 8257, 8379 ] }
480
WALLToken
WALLToken.sol
0x02b6361bbec213bcc34756bbd2877831d92a6c84
Solidity
WALLToken
contract WALLToken is ERC20Token, Wallet, LockSlots, WALLIcoDates { // Utility variable uint constant E18 = 10**18; // Basic token data string public constant name = "Wall Street Decentral Token"; string public constant symbol = "WALL"; uint8 public constant decimals = 18; // Token number of possible tokens in existance 3333333333 uint public constant MAX_TOTAL_TOKEN_SUPPLY = 3333333333 * E18; // ICO parameters // Opening ETH Rate: USD$1827.28 // Therefore, 1 ETH = 45682 WALL uint public tokensPerEth = 45682; // USD$2,000,000/1827.28 = 1094.523006 ether // 1094.523006 ether/2551 addresses = 0.429056450 ether per address for the first 24 hours // 65,999,999,988 MainNet Coins / 19.79999999838 = 3,333,333,333 Tokens Total Supply uint public constant MINIMUM_CONTRIBUTION = 0.2 ether; uint public constant MAXIMUM_FIRST_DAY_CONTRIBUTION = 0.429056450 ether; uint public constant TOKEN_MAIN_CAP = 50000000 * E18; bool public tokensTradeable; // whitelisting mapping(address => bool) public whitelist; uint public numberWhitelisted; // track main sale uint public tokensMain; mapping(address => uint) public balancesMain; uint public totalEthContributed; mapping(address => uint) public ethContributed; // tracking tokens minted uint public tokensMinted; mapping(address => uint) public balancesMinted; mapping(address => mapping(uint => uint)) public balancesMintedByType; // migration variable bool public isMigrationPhaseOpen; // Events --------------------------------------------- event UpdatedTokensPerEth(uint tokensPerEth); event Whitelisted(address indexed account, uint countWhitelisted); event TokensMinted(uint indexed mintType, address indexed account, uint tokens, uint term); event RegisterContribution(address indexed account, uint tokensIssued, uint ethContributed, uint ethReturned); event TokenExchangeRequested(address indexed account, uint tokens); // Basic Functions ------------------------------------ constructor() public {} function () public payable { buyTokens(); } // Information functions function availableToMint() public view returns (uint) { return MAX_TOTAL_TOKEN_SUPPLY.sub(TOKEN_MAIN_CAP).sub(tokensMinted); } function firstDayTokenLimit() public view returns (uint) { return ethToTokens(MAXIMUM_FIRST_DAY_CONTRIBUTION); } function ethToTokens(uint _eth) public view returns (uint tokens) { tokens = _eth.mul(tokensPerEth); } function tokensToEth(uint _tokens) public view returns (uint eth) { eth = _tokens / tokensPerEth; } // Admin functions function addToWhitelist(address _account) public onlyAdmin { pWhitelist(_account); } function addToWhitelistMultiple(address[] _addresses) public onlyAdmin { for (uint i; i < _addresses.length; i++) { pWhitelist(_addresses[i]); } } function pWhitelist(address _account) internal { if (whitelist[_account]) return; whitelist[_account] = true; numberWhitelisted = numberWhitelisted.add(1); emit Whitelisted(_account, numberWhitelisted); } // Owner functions ------------------------------------ function updateTokensPerEth(uint _tokens_per_eth) public onlyOwner { require(now < dateMainStart); tokensPerEth = _tokens_per_eth; emit UpdatedTokensPerEth(tokensPerEth); } // Only owner can make tokens tradable at any time, or if the date is // greater than the end of the mainsale date plus 20 weeks, allow // any caller to make tokensTradeable. function makeTradeable() public { require(msg.sender == owner || now > dateMainEnd + 20 weeks); tokensTradeable = true; } function openMigrationPhase() public onlyOwner { require(now > dateMainEnd); isMigrationPhaseOpen = true; } // Token minting -------------------------------------- function mintTokens(uint _mint_type, address _account, uint _tokens) public onlyOwner { pMintTokens(_mint_type, _account, _tokens, 0); } function mintTokensMultiple(uint _mint_type, address[] _accounts, uint[] _tokens) public onlyOwner { require(_accounts.length == _tokens.length); for (uint i; i < _accounts.length; i++) { pMintTokens(_mint_type, _accounts[i], _tokens[i], 0); } } function mintTokensLocked(uint _mint_type, address _account, uint _tokens, uint _term) public onlyOwner { pMintTokens(_mint_type, _account, _tokens, _term); } function mintTokensLockedMultiple(uint _mint_type, address[] _accounts, uint[] _tokens, uint[] _terms) public onlyOwner { require(_accounts.length == _tokens.length); require(_accounts.length == _terms.length); for (uint i; i < _accounts.length; i++) { pMintTokens(_mint_type, _accounts[i], _tokens[i], _terms[i]); } } function pMintTokens(uint _mint_type, address _account, uint _tokens, uint _term) private { require(whitelist[_account]); require(_account != 0x0); require(_tokens > 0); require(_tokens <= availableToMint(), "not enough tokens available to mint"); require(_term == 0 || _term > now, "either without lock term, or lock term must be in the future"); // register locked tokens (will throw if no slot is found) if (_term > 0) registerLockedTokens(_account, _tokens, _term); // update balances[_account] = balances[_account].add(_tokens); balancesMinted[_account] = balancesMinted[_account].add(_tokens); balancesMintedByType[_account][_mint_type] = balancesMintedByType[_account][_mint_type].add(_tokens); tokensMinted = tokensMinted.add(_tokens); tokensIssuedTotal = tokensIssuedTotal.add(_tokens); // log event emit Transfer(0x0, _account, _tokens); emit TokensMinted(_mint_type, _account, _tokens, _term); } // Main sale ------------------------------------------ function buyTokens() private { require(isMain()); require(msg.value >= MINIMUM_CONTRIBUTION); require(whitelist[msg.sender]); uint tokens_available = TOKEN_MAIN_CAP.sub(tokensMain); // adjust tokens_available on first day, if necessary if (isMainFirstDay()) { uint tokens_available_first_day = firstDayTokenLimit().sub(balancesMain[msg.sender]); if (tokens_available_first_day < tokens_available) { tokens_available = tokens_available_first_day; } } require (tokens_available > 0); uint tokens_requested = ethToTokens(msg.value); uint tokens_issued = tokens_requested; uint eth_contributed = msg.value; uint eth_returned; if (tokens_requested > tokens_available) { tokens_issued = tokens_available; eth_returned = tokensToEth(tokens_requested.sub(tokens_available)); eth_contributed = msg.value.sub(eth_returned); } balances[msg.sender] = balances[msg.sender].add(tokens_issued); balancesMain[msg.sender] = balancesMain[msg.sender].add(tokens_issued); tokensMain = tokensMain.add(tokens_issued); tokensIssuedTotal = tokensIssuedTotal.add(tokens_issued); ethContributed[msg.sender] = ethContributed[msg.sender].add(eth_contributed); totalEthContributed = totalEthContributed.add(eth_contributed); // ether transfers if (eth_returned > 0) msg.sender.transfer(eth_returned); wallet.transfer(eth_contributed); // log emit Transfer(0x0, msg.sender, tokens_issued); emit RegisterContribution(msg.sender, tokens_issued, eth_contributed, eth_returned); } // Token exchange / migration to new platform --------- function requestTokenExchangeMax() public { requestTokenExchange(unlockedTokensInternal(msg.sender)); } function requestTokenExchange(uint _tokens) public { require(isMigrationPhaseOpen); require(_tokens > 0 && _tokens <= unlockedTokensInternal(msg.sender)); balances[msg.sender] = balances[msg.sender].sub(_tokens); tokensIssuedTotal = tokensIssuedTotal.sub(_tokens); emit Transfer(msg.sender, 0x0, _tokens); emit TokenExchangeRequested(msg.sender, _tokens); } // ERC20 functions ------------------- /* Transfer out any accidentally sent ERC20 tokens */ function transferAnyERC20Token(address _token_address, uint _amount) public onlyOwner returns (bool success) { return ERC20Interface(_token_address).transfer(owner, _amount); } /* Override "transfer" */ function transfer(address _to, uint _amount) public returns (bool success) { require(tokensTradeable); require(_amount <= unlockedTokensInternal(msg.sender)); return super.transfer(_to, _amount); } /* Override "transferFrom" */ function transferFrom(address _from, address _to, uint _amount) public returns (bool success) { require(tokensTradeable); require(_amount <= unlockedTokensInternal(_from)); return super.transferFrom(_from, _to, _amount); } /* Multiple token transfers from one address to save gas */ function transferMultiple(address[] _addresses, uint[] _amounts) external { require(_addresses.length <= 100); require(_addresses.length == _amounts.length); // do the transfers for (uint j; j < _addresses.length; j++) { transfer(_addresses[j], _amounts[j]); } } }
// ---------------------------------------------------------------------------- // // WALL public token sale // // ----------------------------------------------------------------------------
LineComment
transferAnyERC20Token
function transferAnyERC20Token(address _token_address, uint _amount) public onlyOwner returns (bool success) { return ERC20Interface(_token_address).transfer(owner, _amount); }
/* Transfer out any accidentally sent ERC20 tokens */
Comment
v0.4.23+commit.124ca40d
None
bzzr://cf4e1a54ac982d46286798e77068beb9d6d9b34248c3bc96ef668b7eb7004ff3
{ "func_code_index": [ 8913, 9108 ] }
481
WALLToken
WALLToken.sol
0x02b6361bbec213bcc34756bbd2877831d92a6c84
Solidity
WALLToken
contract WALLToken is ERC20Token, Wallet, LockSlots, WALLIcoDates { // Utility variable uint constant E18 = 10**18; // Basic token data string public constant name = "Wall Street Decentral Token"; string public constant symbol = "WALL"; uint8 public constant decimals = 18; // Token number of possible tokens in existance 3333333333 uint public constant MAX_TOTAL_TOKEN_SUPPLY = 3333333333 * E18; // ICO parameters // Opening ETH Rate: USD$1827.28 // Therefore, 1 ETH = 45682 WALL uint public tokensPerEth = 45682; // USD$2,000,000/1827.28 = 1094.523006 ether // 1094.523006 ether/2551 addresses = 0.429056450 ether per address for the first 24 hours // 65,999,999,988 MainNet Coins / 19.79999999838 = 3,333,333,333 Tokens Total Supply uint public constant MINIMUM_CONTRIBUTION = 0.2 ether; uint public constant MAXIMUM_FIRST_DAY_CONTRIBUTION = 0.429056450 ether; uint public constant TOKEN_MAIN_CAP = 50000000 * E18; bool public tokensTradeable; // whitelisting mapping(address => bool) public whitelist; uint public numberWhitelisted; // track main sale uint public tokensMain; mapping(address => uint) public balancesMain; uint public totalEthContributed; mapping(address => uint) public ethContributed; // tracking tokens minted uint public tokensMinted; mapping(address => uint) public balancesMinted; mapping(address => mapping(uint => uint)) public balancesMintedByType; // migration variable bool public isMigrationPhaseOpen; // Events --------------------------------------------- event UpdatedTokensPerEth(uint tokensPerEth); event Whitelisted(address indexed account, uint countWhitelisted); event TokensMinted(uint indexed mintType, address indexed account, uint tokens, uint term); event RegisterContribution(address indexed account, uint tokensIssued, uint ethContributed, uint ethReturned); event TokenExchangeRequested(address indexed account, uint tokens); // Basic Functions ------------------------------------ constructor() public {} function () public payable { buyTokens(); } // Information functions function availableToMint() public view returns (uint) { return MAX_TOTAL_TOKEN_SUPPLY.sub(TOKEN_MAIN_CAP).sub(tokensMinted); } function firstDayTokenLimit() public view returns (uint) { return ethToTokens(MAXIMUM_FIRST_DAY_CONTRIBUTION); } function ethToTokens(uint _eth) public view returns (uint tokens) { tokens = _eth.mul(tokensPerEth); } function tokensToEth(uint _tokens) public view returns (uint eth) { eth = _tokens / tokensPerEth; } // Admin functions function addToWhitelist(address _account) public onlyAdmin { pWhitelist(_account); } function addToWhitelistMultiple(address[] _addresses) public onlyAdmin { for (uint i; i < _addresses.length; i++) { pWhitelist(_addresses[i]); } } function pWhitelist(address _account) internal { if (whitelist[_account]) return; whitelist[_account] = true; numberWhitelisted = numberWhitelisted.add(1); emit Whitelisted(_account, numberWhitelisted); } // Owner functions ------------------------------------ function updateTokensPerEth(uint _tokens_per_eth) public onlyOwner { require(now < dateMainStart); tokensPerEth = _tokens_per_eth; emit UpdatedTokensPerEth(tokensPerEth); } // Only owner can make tokens tradable at any time, or if the date is // greater than the end of the mainsale date plus 20 weeks, allow // any caller to make tokensTradeable. function makeTradeable() public { require(msg.sender == owner || now > dateMainEnd + 20 weeks); tokensTradeable = true; } function openMigrationPhase() public onlyOwner { require(now > dateMainEnd); isMigrationPhaseOpen = true; } // Token minting -------------------------------------- function mintTokens(uint _mint_type, address _account, uint _tokens) public onlyOwner { pMintTokens(_mint_type, _account, _tokens, 0); } function mintTokensMultiple(uint _mint_type, address[] _accounts, uint[] _tokens) public onlyOwner { require(_accounts.length == _tokens.length); for (uint i; i < _accounts.length; i++) { pMintTokens(_mint_type, _accounts[i], _tokens[i], 0); } } function mintTokensLocked(uint _mint_type, address _account, uint _tokens, uint _term) public onlyOwner { pMintTokens(_mint_type, _account, _tokens, _term); } function mintTokensLockedMultiple(uint _mint_type, address[] _accounts, uint[] _tokens, uint[] _terms) public onlyOwner { require(_accounts.length == _tokens.length); require(_accounts.length == _terms.length); for (uint i; i < _accounts.length; i++) { pMintTokens(_mint_type, _accounts[i], _tokens[i], _terms[i]); } } function pMintTokens(uint _mint_type, address _account, uint _tokens, uint _term) private { require(whitelist[_account]); require(_account != 0x0); require(_tokens > 0); require(_tokens <= availableToMint(), "not enough tokens available to mint"); require(_term == 0 || _term > now, "either without lock term, or lock term must be in the future"); // register locked tokens (will throw if no slot is found) if (_term > 0) registerLockedTokens(_account, _tokens, _term); // update balances[_account] = balances[_account].add(_tokens); balancesMinted[_account] = balancesMinted[_account].add(_tokens); balancesMintedByType[_account][_mint_type] = balancesMintedByType[_account][_mint_type].add(_tokens); tokensMinted = tokensMinted.add(_tokens); tokensIssuedTotal = tokensIssuedTotal.add(_tokens); // log event emit Transfer(0x0, _account, _tokens); emit TokensMinted(_mint_type, _account, _tokens, _term); } // Main sale ------------------------------------------ function buyTokens() private { require(isMain()); require(msg.value >= MINIMUM_CONTRIBUTION); require(whitelist[msg.sender]); uint tokens_available = TOKEN_MAIN_CAP.sub(tokensMain); // adjust tokens_available on first day, if necessary if (isMainFirstDay()) { uint tokens_available_first_day = firstDayTokenLimit().sub(balancesMain[msg.sender]); if (tokens_available_first_day < tokens_available) { tokens_available = tokens_available_first_day; } } require (tokens_available > 0); uint tokens_requested = ethToTokens(msg.value); uint tokens_issued = tokens_requested; uint eth_contributed = msg.value; uint eth_returned; if (tokens_requested > tokens_available) { tokens_issued = tokens_available; eth_returned = tokensToEth(tokens_requested.sub(tokens_available)); eth_contributed = msg.value.sub(eth_returned); } balances[msg.sender] = balances[msg.sender].add(tokens_issued); balancesMain[msg.sender] = balancesMain[msg.sender].add(tokens_issued); tokensMain = tokensMain.add(tokens_issued); tokensIssuedTotal = tokensIssuedTotal.add(tokens_issued); ethContributed[msg.sender] = ethContributed[msg.sender].add(eth_contributed); totalEthContributed = totalEthContributed.add(eth_contributed); // ether transfers if (eth_returned > 0) msg.sender.transfer(eth_returned); wallet.transfer(eth_contributed); // log emit Transfer(0x0, msg.sender, tokens_issued); emit RegisterContribution(msg.sender, tokens_issued, eth_contributed, eth_returned); } // Token exchange / migration to new platform --------- function requestTokenExchangeMax() public { requestTokenExchange(unlockedTokensInternal(msg.sender)); } function requestTokenExchange(uint _tokens) public { require(isMigrationPhaseOpen); require(_tokens > 0 && _tokens <= unlockedTokensInternal(msg.sender)); balances[msg.sender] = balances[msg.sender].sub(_tokens); tokensIssuedTotal = tokensIssuedTotal.sub(_tokens); emit Transfer(msg.sender, 0x0, _tokens); emit TokenExchangeRequested(msg.sender, _tokens); } // ERC20 functions ------------------- /* Transfer out any accidentally sent ERC20 tokens */ function transferAnyERC20Token(address _token_address, uint _amount) public onlyOwner returns (bool success) { return ERC20Interface(_token_address).transfer(owner, _amount); } /* Override "transfer" */ function transfer(address _to, uint _amount) public returns (bool success) { require(tokensTradeable); require(_amount <= unlockedTokensInternal(msg.sender)); return super.transfer(_to, _amount); } /* Override "transferFrom" */ function transferFrom(address _from, address _to, uint _amount) public returns (bool success) { require(tokensTradeable); require(_amount <= unlockedTokensInternal(_from)); return super.transferFrom(_from, _to, _amount); } /* Multiple token transfers from one address to save gas */ function transferMultiple(address[] _addresses, uint[] _amounts) external { require(_addresses.length <= 100); require(_addresses.length == _amounts.length); // do the transfers for (uint j; j < _addresses.length; j++) { transfer(_addresses[j], _amounts[j]); } } }
// ---------------------------------------------------------------------------- // // WALL public token sale // // ----------------------------------------------------------------------------
LineComment
transfer
function transfer(address _to, uint _amount) public returns (bool success) { require(tokensTradeable); require(_amount <= unlockedTokensInternal(msg.sender)); return super.transfer(_to, _amount); }
/* Override "transfer" */
Comment
v0.4.23+commit.124ca40d
None
bzzr://cf4e1a54ac982d46286798e77068beb9d6d9b34248c3bc96ef668b7eb7004ff3
{ "func_code_index": [ 9144, 9378 ] }
482
WALLToken
WALLToken.sol
0x02b6361bbec213bcc34756bbd2877831d92a6c84
Solidity
WALLToken
contract WALLToken is ERC20Token, Wallet, LockSlots, WALLIcoDates { // Utility variable uint constant E18 = 10**18; // Basic token data string public constant name = "Wall Street Decentral Token"; string public constant symbol = "WALL"; uint8 public constant decimals = 18; // Token number of possible tokens in existance 3333333333 uint public constant MAX_TOTAL_TOKEN_SUPPLY = 3333333333 * E18; // ICO parameters // Opening ETH Rate: USD$1827.28 // Therefore, 1 ETH = 45682 WALL uint public tokensPerEth = 45682; // USD$2,000,000/1827.28 = 1094.523006 ether // 1094.523006 ether/2551 addresses = 0.429056450 ether per address for the first 24 hours // 65,999,999,988 MainNet Coins / 19.79999999838 = 3,333,333,333 Tokens Total Supply uint public constant MINIMUM_CONTRIBUTION = 0.2 ether; uint public constant MAXIMUM_FIRST_DAY_CONTRIBUTION = 0.429056450 ether; uint public constant TOKEN_MAIN_CAP = 50000000 * E18; bool public tokensTradeable; // whitelisting mapping(address => bool) public whitelist; uint public numberWhitelisted; // track main sale uint public tokensMain; mapping(address => uint) public balancesMain; uint public totalEthContributed; mapping(address => uint) public ethContributed; // tracking tokens minted uint public tokensMinted; mapping(address => uint) public balancesMinted; mapping(address => mapping(uint => uint)) public balancesMintedByType; // migration variable bool public isMigrationPhaseOpen; // Events --------------------------------------------- event UpdatedTokensPerEth(uint tokensPerEth); event Whitelisted(address indexed account, uint countWhitelisted); event TokensMinted(uint indexed mintType, address indexed account, uint tokens, uint term); event RegisterContribution(address indexed account, uint tokensIssued, uint ethContributed, uint ethReturned); event TokenExchangeRequested(address indexed account, uint tokens); // Basic Functions ------------------------------------ constructor() public {} function () public payable { buyTokens(); } // Information functions function availableToMint() public view returns (uint) { return MAX_TOTAL_TOKEN_SUPPLY.sub(TOKEN_MAIN_CAP).sub(tokensMinted); } function firstDayTokenLimit() public view returns (uint) { return ethToTokens(MAXIMUM_FIRST_DAY_CONTRIBUTION); } function ethToTokens(uint _eth) public view returns (uint tokens) { tokens = _eth.mul(tokensPerEth); } function tokensToEth(uint _tokens) public view returns (uint eth) { eth = _tokens / tokensPerEth; } // Admin functions function addToWhitelist(address _account) public onlyAdmin { pWhitelist(_account); } function addToWhitelistMultiple(address[] _addresses) public onlyAdmin { for (uint i; i < _addresses.length; i++) { pWhitelist(_addresses[i]); } } function pWhitelist(address _account) internal { if (whitelist[_account]) return; whitelist[_account] = true; numberWhitelisted = numberWhitelisted.add(1); emit Whitelisted(_account, numberWhitelisted); } // Owner functions ------------------------------------ function updateTokensPerEth(uint _tokens_per_eth) public onlyOwner { require(now < dateMainStart); tokensPerEth = _tokens_per_eth; emit UpdatedTokensPerEth(tokensPerEth); } // Only owner can make tokens tradable at any time, or if the date is // greater than the end of the mainsale date plus 20 weeks, allow // any caller to make tokensTradeable. function makeTradeable() public { require(msg.sender == owner || now > dateMainEnd + 20 weeks); tokensTradeable = true; } function openMigrationPhase() public onlyOwner { require(now > dateMainEnd); isMigrationPhaseOpen = true; } // Token minting -------------------------------------- function mintTokens(uint _mint_type, address _account, uint _tokens) public onlyOwner { pMintTokens(_mint_type, _account, _tokens, 0); } function mintTokensMultiple(uint _mint_type, address[] _accounts, uint[] _tokens) public onlyOwner { require(_accounts.length == _tokens.length); for (uint i; i < _accounts.length; i++) { pMintTokens(_mint_type, _accounts[i], _tokens[i], 0); } } function mintTokensLocked(uint _mint_type, address _account, uint _tokens, uint _term) public onlyOwner { pMintTokens(_mint_type, _account, _tokens, _term); } function mintTokensLockedMultiple(uint _mint_type, address[] _accounts, uint[] _tokens, uint[] _terms) public onlyOwner { require(_accounts.length == _tokens.length); require(_accounts.length == _terms.length); for (uint i; i < _accounts.length; i++) { pMintTokens(_mint_type, _accounts[i], _tokens[i], _terms[i]); } } function pMintTokens(uint _mint_type, address _account, uint _tokens, uint _term) private { require(whitelist[_account]); require(_account != 0x0); require(_tokens > 0); require(_tokens <= availableToMint(), "not enough tokens available to mint"); require(_term == 0 || _term > now, "either without lock term, or lock term must be in the future"); // register locked tokens (will throw if no slot is found) if (_term > 0) registerLockedTokens(_account, _tokens, _term); // update balances[_account] = balances[_account].add(_tokens); balancesMinted[_account] = balancesMinted[_account].add(_tokens); balancesMintedByType[_account][_mint_type] = balancesMintedByType[_account][_mint_type].add(_tokens); tokensMinted = tokensMinted.add(_tokens); tokensIssuedTotal = tokensIssuedTotal.add(_tokens); // log event emit Transfer(0x0, _account, _tokens); emit TokensMinted(_mint_type, _account, _tokens, _term); } // Main sale ------------------------------------------ function buyTokens() private { require(isMain()); require(msg.value >= MINIMUM_CONTRIBUTION); require(whitelist[msg.sender]); uint tokens_available = TOKEN_MAIN_CAP.sub(tokensMain); // adjust tokens_available on first day, if necessary if (isMainFirstDay()) { uint tokens_available_first_day = firstDayTokenLimit().sub(balancesMain[msg.sender]); if (tokens_available_first_day < tokens_available) { tokens_available = tokens_available_first_day; } } require (tokens_available > 0); uint tokens_requested = ethToTokens(msg.value); uint tokens_issued = tokens_requested; uint eth_contributed = msg.value; uint eth_returned; if (tokens_requested > tokens_available) { tokens_issued = tokens_available; eth_returned = tokensToEth(tokens_requested.sub(tokens_available)); eth_contributed = msg.value.sub(eth_returned); } balances[msg.sender] = balances[msg.sender].add(tokens_issued); balancesMain[msg.sender] = balancesMain[msg.sender].add(tokens_issued); tokensMain = tokensMain.add(tokens_issued); tokensIssuedTotal = tokensIssuedTotal.add(tokens_issued); ethContributed[msg.sender] = ethContributed[msg.sender].add(eth_contributed); totalEthContributed = totalEthContributed.add(eth_contributed); // ether transfers if (eth_returned > 0) msg.sender.transfer(eth_returned); wallet.transfer(eth_contributed); // log emit Transfer(0x0, msg.sender, tokens_issued); emit RegisterContribution(msg.sender, tokens_issued, eth_contributed, eth_returned); } // Token exchange / migration to new platform --------- function requestTokenExchangeMax() public { requestTokenExchange(unlockedTokensInternal(msg.sender)); } function requestTokenExchange(uint _tokens) public { require(isMigrationPhaseOpen); require(_tokens > 0 && _tokens <= unlockedTokensInternal(msg.sender)); balances[msg.sender] = balances[msg.sender].sub(_tokens); tokensIssuedTotal = tokensIssuedTotal.sub(_tokens); emit Transfer(msg.sender, 0x0, _tokens); emit TokenExchangeRequested(msg.sender, _tokens); } // ERC20 functions ------------------- /* Transfer out any accidentally sent ERC20 tokens */ function transferAnyERC20Token(address _token_address, uint _amount) public onlyOwner returns (bool success) { return ERC20Interface(_token_address).transfer(owner, _amount); } /* Override "transfer" */ function transfer(address _to, uint _amount) public returns (bool success) { require(tokensTradeable); require(_amount <= unlockedTokensInternal(msg.sender)); return super.transfer(_to, _amount); } /* Override "transferFrom" */ function transferFrom(address _from, address _to, uint _amount) public returns (bool success) { require(tokensTradeable); require(_amount <= unlockedTokensInternal(_from)); return super.transferFrom(_from, _to, _amount); } /* Multiple token transfers from one address to save gas */ function transferMultiple(address[] _addresses, uint[] _amounts) external { require(_addresses.length <= 100); require(_addresses.length == _amounts.length); // do the transfers for (uint j; j < _addresses.length; j++) { transfer(_addresses[j], _amounts[j]); } } }
// ---------------------------------------------------------------------------- // // WALL public token sale // // ----------------------------------------------------------------------------
LineComment
transferFrom
function transferFrom(address _from, address _to, uint _amount) public returns (bool success) { require(tokensTradeable); require(_amount <= unlockedTokensInternal(_from)); return super.transferFrom(_from, _to, _amount); }
/* Override "transferFrom" */
Comment
v0.4.23+commit.124ca40d
None
bzzr://cf4e1a54ac982d46286798e77068beb9d6d9b34248c3bc96ef668b7eb7004ff3
{ "func_code_index": [ 9418, 9677 ] }
483
WALLToken
WALLToken.sol
0x02b6361bbec213bcc34756bbd2877831d92a6c84
Solidity
WALLToken
contract WALLToken is ERC20Token, Wallet, LockSlots, WALLIcoDates { // Utility variable uint constant E18 = 10**18; // Basic token data string public constant name = "Wall Street Decentral Token"; string public constant symbol = "WALL"; uint8 public constant decimals = 18; // Token number of possible tokens in existance 3333333333 uint public constant MAX_TOTAL_TOKEN_SUPPLY = 3333333333 * E18; // ICO parameters // Opening ETH Rate: USD$1827.28 // Therefore, 1 ETH = 45682 WALL uint public tokensPerEth = 45682; // USD$2,000,000/1827.28 = 1094.523006 ether // 1094.523006 ether/2551 addresses = 0.429056450 ether per address for the first 24 hours // 65,999,999,988 MainNet Coins / 19.79999999838 = 3,333,333,333 Tokens Total Supply uint public constant MINIMUM_CONTRIBUTION = 0.2 ether; uint public constant MAXIMUM_FIRST_DAY_CONTRIBUTION = 0.429056450 ether; uint public constant TOKEN_MAIN_CAP = 50000000 * E18; bool public tokensTradeable; // whitelisting mapping(address => bool) public whitelist; uint public numberWhitelisted; // track main sale uint public tokensMain; mapping(address => uint) public balancesMain; uint public totalEthContributed; mapping(address => uint) public ethContributed; // tracking tokens minted uint public tokensMinted; mapping(address => uint) public balancesMinted; mapping(address => mapping(uint => uint)) public balancesMintedByType; // migration variable bool public isMigrationPhaseOpen; // Events --------------------------------------------- event UpdatedTokensPerEth(uint tokensPerEth); event Whitelisted(address indexed account, uint countWhitelisted); event TokensMinted(uint indexed mintType, address indexed account, uint tokens, uint term); event RegisterContribution(address indexed account, uint tokensIssued, uint ethContributed, uint ethReturned); event TokenExchangeRequested(address indexed account, uint tokens); // Basic Functions ------------------------------------ constructor() public {} function () public payable { buyTokens(); } // Information functions function availableToMint() public view returns (uint) { return MAX_TOTAL_TOKEN_SUPPLY.sub(TOKEN_MAIN_CAP).sub(tokensMinted); } function firstDayTokenLimit() public view returns (uint) { return ethToTokens(MAXIMUM_FIRST_DAY_CONTRIBUTION); } function ethToTokens(uint _eth) public view returns (uint tokens) { tokens = _eth.mul(tokensPerEth); } function tokensToEth(uint _tokens) public view returns (uint eth) { eth = _tokens / tokensPerEth; } // Admin functions function addToWhitelist(address _account) public onlyAdmin { pWhitelist(_account); } function addToWhitelistMultiple(address[] _addresses) public onlyAdmin { for (uint i; i < _addresses.length; i++) { pWhitelist(_addresses[i]); } } function pWhitelist(address _account) internal { if (whitelist[_account]) return; whitelist[_account] = true; numberWhitelisted = numberWhitelisted.add(1); emit Whitelisted(_account, numberWhitelisted); } // Owner functions ------------------------------------ function updateTokensPerEth(uint _tokens_per_eth) public onlyOwner { require(now < dateMainStart); tokensPerEth = _tokens_per_eth; emit UpdatedTokensPerEth(tokensPerEth); } // Only owner can make tokens tradable at any time, or if the date is // greater than the end of the mainsale date plus 20 weeks, allow // any caller to make tokensTradeable. function makeTradeable() public { require(msg.sender == owner || now > dateMainEnd + 20 weeks); tokensTradeable = true; } function openMigrationPhase() public onlyOwner { require(now > dateMainEnd); isMigrationPhaseOpen = true; } // Token minting -------------------------------------- function mintTokens(uint _mint_type, address _account, uint _tokens) public onlyOwner { pMintTokens(_mint_type, _account, _tokens, 0); } function mintTokensMultiple(uint _mint_type, address[] _accounts, uint[] _tokens) public onlyOwner { require(_accounts.length == _tokens.length); for (uint i; i < _accounts.length; i++) { pMintTokens(_mint_type, _accounts[i], _tokens[i], 0); } } function mintTokensLocked(uint _mint_type, address _account, uint _tokens, uint _term) public onlyOwner { pMintTokens(_mint_type, _account, _tokens, _term); } function mintTokensLockedMultiple(uint _mint_type, address[] _accounts, uint[] _tokens, uint[] _terms) public onlyOwner { require(_accounts.length == _tokens.length); require(_accounts.length == _terms.length); for (uint i; i < _accounts.length; i++) { pMintTokens(_mint_type, _accounts[i], _tokens[i], _terms[i]); } } function pMintTokens(uint _mint_type, address _account, uint _tokens, uint _term) private { require(whitelist[_account]); require(_account != 0x0); require(_tokens > 0); require(_tokens <= availableToMint(), "not enough tokens available to mint"); require(_term == 0 || _term > now, "either without lock term, or lock term must be in the future"); // register locked tokens (will throw if no slot is found) if (_term > 0) registerLockedTokens(_account, _tokens, _term); // update balances[_account] = balances[_account].add(_tokens); balancesMinted[_account] = balancesMinted[_account].add(_tokens); balancesMintedByType[_account][_mint_type] = balancesMintedByType[_account][_mint_type].add(_tokens); tokensMinted = tokensMinted.add(_tokens); tokensIssuedTotal = tokensIssuedTotal.add(_tokens); // log event emit Transfer(0x0, _account, _tokens); emit TokensMinted(_mint_type, _account, _tokens, _term); } // Main sale ------------------------------------------ function buyTokens() private { require(isMain()); require(msg.value >= MINIMUM_CONTRIBUTION); require(whitelist[msg.sender]); uint tokens_available = TOKEN_MAIN_CAP.sub(tokensMain); // adjust tokens_available on first day, if necessary if (isMainFirstDay()) { uint tokens_available_first_day = firstDayTokenLimit().sub(balancesMain[msg.sender]); if (tokens_available_first_day < tokens_available) { tokens_available = tokens_available_first_day; } } require (tokens_available > 0); uint tokens_requested = ethToTokens(msg.value); uint tokens_issued = tokens_requested; uint eth_contributed = msg.value; uint eth_returned; if (tokens_requested > tokens_available) { tokens_issued = tokens_available; eth_returned = tokensToEth(tokens_requested.sub(tokens_available)); eth_contributed = msg.value.sub(eth_returned); } balances[msg.sender] = balances[msg.sender].add(tokens_issued); balancesMain[msg.sender] = balancesMain[msg.sender].add(tokens_issued); tokensMain = tokensMain.add(tokens_issued); tokensIssuedTotal = tokensIssuedTotal.add(tokens_issued); ethContributed[msg.sender] = ethContributed[msg.sender].add(eth_contributed); totalEthContributed = totalEthContributed.add(eth_contributed); // ether transfers if (eth_returned > 0) msg.sender.transfer(eth_returned); wallet.transfer(eth_contributed); // log emit Transfer(0x0, msg.sender, tokens_issued); emit RegisterContribution(msg.sender, tokens_issued, eth_contributed, eth_returned); } // Token exchange / migration to new platform --------- function requestTokenExchangeMax() public { requestTokenExchange(unlockedTokensInternal(msg.sender)); } function requestTokenExchange(uint _tokens) public { require(isMigrationPhaseOpen); require(_tokens > 0 && _tokens <= unlockedTokensInternal(msg.sender)); balances[msg.sender] = balances[msg.sender].sub(_tokens); tokensIssuedTotal = tokensIssuedTotal.sub(_tokens); emit Transfer(msg.sender, 0x0, _tokens); emit TokenExchangeRequested(msg.sender, _tokens); } // ERC20 functions ------------------- /* Transfer out any accidentally sent ERC20 tokens */ function transferAnyERC20Token(address _token_address, uint _amount) public onlyOwner returns (bool success) { return ERC20Interface(_token_address).transfer(owner, _amount); } /* Override "transfer" */ function transfer(address _to, uint _amount) public returns (bool success) { require(tokensTradeable); require(_amount <= unlockedTokensInternal(msg.sender)); return super.transfer(_to, _amount); } /* Override "transferFrom" */ function transferFrom(address _from, address _to, uint _amount) public returns (bool success) { require(tokensTradeable); require(_amount <= unlockedTokensInternal(_from)); return super.transferFrom(_from, _to, _amount); } /* Multiple token transfers from one address to save gas */ function transferMultiple(address[] _addresses, uint[] _amounts) external { require(_addresses.length <= 100); require(_addresses.length == _amounts.length); // do the transfers for (uint j; j < _addresses.length; j++) { transfer(_addresses[j], _amounts[j]); } } }
// ---------------------------------------------------------------------------- // // WALL public token sale // // ----------------------------------------------------------------------------
LineComment
transferMultiple
function transferMultiple(address[] _addresses, uint[] _amounts) external { require(_addresses.length <= 100); require(_addresses.length == _amounts.length); // do the transfers for (uint j; j < _addresses.length; j++) { transfer(_addresses[j], _amounts[j]); } }
/* Multiple token transfers from one address to save gas */
Comment
v0.4.23+commit.124ca40d
None
bzzr://cf4e1a54ac982d46286798e77068beb9d6d9b34248c3bc96ef668b7eb7004ff3
{ "func_code_index": [ 9747, 10081 ] }
484
TornadoCash_eth
contracts/MerkleTreeWithHistory.sol
0xa160cdab225685da1d56aa342ad8841c3b53f291
Solidity
MerkleTreeWithHistory
contract MerkleTreeWithHistory { uint256 public constant FIELD_SIZE = 21888242871839275222246405745257275088548364400416034343698204186575808495617; uint256 public constant ZERO_VALUE = 21663839004416932945382355908790599225266501822907911457504978515578255421292; // = keccak256("tornado") % FIELD_SIZE uint32 public levels; // the following variables are made public for easier testing and debugging and // are not supposed to be accessed in regular code bytes32[] public filledSubtrees; bytes32[] public zeros; uint32 public currentRootIndex = 0; uint32 public nextIndex = 0; uint32 public constant ROOT_HISTORY_SIZE = 100; bytes32[ROOT_HISTORY_SIZE] public roots; constructor(uint32 _treeLevels) public { require(_treeLevels > 0, "_treeLevels should be greater than zero"); require(_treeLevels < 32, "_treeLevels should be less than 32"); levels = _treeLevels; bytes32 currentZero = bytes32(ZERO_VALUE); zeros.push(currentZero); filledSubtrees.push(currentZero); for (uint32 i = 1; i < levels; i++) { currentZero = hashLeftRight(currentZero, currentZero); zeros.push(currentZero); filledSubtrees.push(currentZero); } roots[0] = hashLeftRight(currentZero, currentZero); } /** @dev Hash 2 tree leaves, returns MiMC(_left, _right) */ function hashLeftRight(bytes32 _left, bytes32 _right) public pure returns (bytes32) { require(uint256(_left) < FIELD_SIZE, "_left should be inside the field"); require(uint256(_right) < FIELD_SIZE, "_right should be inside the field"); uint256 R = uint256(_left); uint256 C = 0; (R, C) = Hasher.MiMCSponge(R, C); R = addmod(R, uint256(_right), FIELD_SIZE); (R, C) = Hasher.MiMCSponge(R, C); return bytes32(R); } function _insert(bytes32 _leaf) internal returns(uint32 index) { uint32 currentIndex = nextIndex; require(currentIndex != uint32(2)**levels, "Merkle tree is full. No more leafs can be added"); nextIndex += 1; bytes32 currentLevelHash = _leaf; bytes32 left; bytes32 right; for (uint32 i = 0; i < levels; i++) { if (currentIndex % 2 == 0) { left = currentLevelHash; right = zeros[i]; filledSubtrees[i] = currentLevelHash; } else { left = filledSubtrees[i]; right = currentLevelHash; } currentLevelHash = hashLeftRight(left, right); currentIndex /= 2; } currentRootIndex = (currentRootIndex + 1) % ROOT_HISTORY_SIZE; roots[currentRootIndex] = currentLevelHash; return nextIndex - 1; } /** @dev Whether the root is present in the root history */ function isKnownRoot(bytes32 _root) public view returns(bool) { if (_root == 0) { return false; } uint32 i = currentRootIndex; do { if (_root == roots[i]) { return true; } if (i == 0) { i = ROOT_HISTORY_SIZE; } i--; } while (i != currentRootIndex); return false; } /** @dev Returns the last root */ function getLastRoot() public view returns(bytes32) { return roots[currentRootIndex]; } }
hashLeftRight
function hashLeftRight(bytes32 _left, bytes32 _right) public pure returns (bytes32) { require(uint256(_left) < FIELD_SIZE, "_left should be inside the field"); require(uint256(_right) < FIELD_SIZE, "_right should be inside the field"); uint256 R = uint256(_left); uint256 C = 0; (R, C) = Hasher.MiMCSponge(R, C); R = addmod(R, uint256(_right), FIELD_SIZE); (R, C) = Hasher.MiMCSponge(R, C); return bytes32(R); }
/** @dev Hash 2 tree leaves, returns MiMC(_left, _right) */
NatSpecMultiLine
v0.5.11+commit.c082d0b4
None
bzzr://587549d2a38eba8d298e5df3a9c389827128193ddbe15c9ca5720461b16a92ac
{ "func_code_index": [ 1366, 1823 ] }
485
TornadoCash_eth
contracts/MerkleTreeWithHistory.sol
0xa160cdab225685da1d56aa342ad8841c3b53f291
Solidity
MerkleTreeWithHistory
contract MerkleTreeWithHistory { uint256 public constant FIELD_SIZE = 21888242871839275222246405745257275088548364400416034343698204186575808495617; uint256 public constant ZERO_VALUE = 21663839004416932945382355908790599225266501822907911457504978515578255421292; // = keccak256("tornado") % FIELD_SIZE uint32 public levels; // the following variables are made public for easier testing and debugging and // are not supposed to be accessed in regular code bytes32[] public filledSubtrees; bytes32[] public zeros; uint32 public currentRootIndex = 0; uint32 public nextIndex = 0; uint32 public constant ROOT_HISTORY_SIZE = 100; bytes32[ROOT_HISTORY_SIZE] public roots; constructor(uint32 _treeLevels) public { require(_treeLevels > 0, "_treeLevels should be greater than zero"); require(_treeLevels < 32, "_treeLevels should be less than 32"); levels = _treeLevels; bytes32 currentZero = bytes32(ZERO_VALUE); zeros.push(currentZero); filledSubtrees.push(currentZero); for (uint32 i = 1; i < levels; i++) { currentZero = hashLeftRight(currentZero, currentZero); zeros.push(currentZero); filledSubtrees.push(currentZero); } roots[0] = hashLeftRight(currentZero, currentZero); } /** @dev Hash 2 tree leaves, returns MiMC(_left, _right) */ function hashLeftRight(bytes32 _left, bytes32 _right) public pure returns (bytes32) { require(uint256(_left) < FIELD_SIZE, "_left should be inside the field"); require(uint256(_right) < FIELD_SIZE, "_right should be inside the field"); uint256 R = uint256(_left); uint256 C = 0; (R, C) = Hasher.MiMCSponge(R, C); R = addmod(R, uint256(_right), FIELD_SIZE); (R, C) = Hasher.MiMCSponge(R, C); return bytes32(R); } function _insert(bytes32 _leaf) internal returns(uint32 index) { uint32 currentIndex = nextIndex; require(currentIndex != uint32(2)**levels, "Merkle tree is full. No more leafs can be added"); nextIndex += 1; bytes32 currentLevelHash = _leaf; bytes32 left; bytes32 right; for (uint32 i = 0; i < levels; i++) { if (currentIndex % 2 == 0) { left = currentLevelHash; right = zeros[i]; filledSubtrees[i] = currentLevelHash; } else { left = filledSubtrees[i]; right = currentLevelHash; } currentLevelHash = hashLeftRight(left, right); currentIndex /= 2; } currentRootIndex = (currentRootIndex + 1) % ROOT_HISTORY_SIZE; roots[currentRootIndex] = currentLevelHash; return nextIndex - 1; } /** @dev Whether the root is present in the root history */ function isKnownRoot(bytes32 _root) public view returns(bool) { if (_root == 0) { return false; } uint32 i = currentRootIndex; do { if (_root == roots[i]) { return true; } if (i == 0) { i = ROOT_HISTORY_SIZE; } i--; } while (i != currentRootIndex); return false; } /** @dev Returns the last root */ function getLastRoot() public view returns(bytes32) { return roots[currentRootIndex]; } }
isKnownRoot
function isKnownRoot(bytes32 _root) public view returns(bool) { if (_root == 0) { return false; } uint32 i = currentRootIndex; do { if (_root == roots[i]) { return true; } if (i == 0) { i = ROOT_HISTORY_SIZE; } i--; } while (i != currentRootIndex); return false; }
/** @dev Whether the root is present in the root history */
NatSpecMultiLine
v0.5.11+commit.c082d0b4
None
bzzr://587549d2a38eba8d298e5df3a9c389827128193ddbe15c9ca5720461b16a92ac
{ "func_code_index": [ 2732, 3092 ] }
486
TornadoCash_eth
contracts/MerkleTreeWithHistory.sol
0xa160cdab225685da1d56aa342ad8841c3b53f291
Solidity
MerkleTreeWithHistory
contract MerkleTreeWithHistory { uint256 public constant FIELD_SIZE = 21888242871839275222246405745257275088548364400416034343698204186575808495617; uint256 public constant ZERO_VALUE = 21663839004416932945382355908790599225266501822907911457504978515578255421292; // = keccak256("tornado") % FIELD_SIZE uint32 public levels; // the following variables are made public for easier testing and debugging and // are not supposed to be accessed in regular code bytes32[] public filledSubtrees; bytes32[] public zeros; uint32 public currentRootIndex = 0; uint32 public nextIndex = 0; uint32 public constant ROOT_HISTORY_SIZE = 100; bytes32[ROOT_HISTORY_SIZE] public roots; constructor(uint32 _treeLevels) public { require(_treeLevels > 0, "_treeLevels should be greater than zero"); require(_treeLevels < 32, "_treeLevels should be less than 32"); levels = _treeLevels; bytes32 currentZero = bytes32(ZERO_VALUE); zeros.push(currentZero); filledSubtrees.push(currentZero); for (uint32 i = 1; i < levels; i++) { currentZero = hashLeftRight(currentZero, currentZero); zeros.push(currentZero); filledSubtrees.push(currentZero); } roots[0] = hashLeftRight(currentZero, currentZero); } /** @dev Hash 2 tree leaves, returns MiMC(_left, _right) */ function hashLeftRight(bytes32 _left, bytes32 _right) public pure returns (bytes32) { require(uint256(_left) < FIELD_SIZE, "_left should be inside the field"); require(uint256(_right) < FIELD_SIZE, "_right should be inside the field"); uint256 R = uint256(_left); uint256 C = 0; (R, C) = Hasher.MiMCSponge(R, C); R = addmod(R, uint256(_right), FIELD_SIZE); (R, C) = Hasher.MiMCSponge(R, C); return bytes32(R); } function _insert(bytes32 _leaf) internal returns(uint32 index) { uint32 currentIndex = nextIndex; require(currentIndex != uint32(2)**levels, "Merkle tree is full. No more leafs can be added"); nextIndex += 1; bytes32 currentLevelHash = _leaf; bytes32 left; bytes32 right; for (uint32 i = 0; i < levels; i++) { if (currentIndex % 2 == 0) { left = currentLevelHash; right = zeros[i]; filledSubtrees[i] = currentLevelHash; } else { left = filledSubtrees[i]; right = currentLevelHash; } currentLevelHash = hashLeftRight(left, right); currentIndex /= 2; } currentRootIndex = (currentRootIndex + 1) % ROOT_HISTORY_SIZE; roots[currentRootIndex] = currentLevelHash; return nextIndex - 1; } /** @dev Whether the root is present in the root history */ function isKnownRoot(bytes32 _root) public view returns(bool) { if (_root == 0) { return false; } uint32 i = currentRootIndex; do { if (_root == roots[i]) { return true; } if (i == 0) { i = ROOT_HISTORY_SIZE; } i--; } while (i != currentRootIndex); return false; } /** @dev Returns the last root */ function getLastRoot() public view returns(bytes32) { return roots[currentRootIndex]; } }
getLastRoot
function getLastRoot() public view returns(bytes32) { return roots[currentRootIndex]; }
/** @dev Returns the last root */
NatSpecMultiLine
v0.5.11+commit.c082d0b4
None
bzzr://587549d2a38eba8d298e5df3a9c389827128193ddbe15c9ca5720461b16a92ac
{ "func_code_index": [ 3140, 3238 ] }
487
StarToken
@openzeppelin/contracts/token/ERC20/ERC20.sol
0x24eb24647786135352cbb14f888b23277f0014e7
Solidity
ERC20
contract ERC20 is Context, IERC20, IERC20Metadata { mapping(address => uint256) private _balances; mapping(address => mapping(address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; /** * @dev Sets the values for {name} and {symbol}. * * The default value of {decimals} is 18. To select a different value for * {decimals} you should overload it. * * All two of these values are immutable: they can only be set once during * construction. */ constructor(string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } /** * @dev Returns the name of the token. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5.05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the value {ERC20} uses, unless this function is * overridden; * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view virtual override returns (uint8) { return 18; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view virtual override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}. * * Requirements: * * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for ``sender``'s tokens of at least * `amount`. */ function transferFrom( address sender, address recipient, uint256 amount ) public virtual override returns (bool) { _transfer(sender, recipient, amount); uint256 currentAllowance = _allowances[sender][_msgSender()]; require(currentAllowance >= amount, "ERC20: transfer amount exceeds allowance"); unchecked { _approve(sender, _msgSender(), currentAllowance - amount); } return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { uint256 currentAllowance = _allowances[_msgSender()][spender]; require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero"); unchecked { _approve(_msgSender(), spender, currentAllowance - subtractedValue); } return true; } /** * @dev Moves `amount` of tokens from `sender` to `recipient`. * * This internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer( address sender, address recipient, uint256 amount ) internal virtual { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(sender, recipient, amount); uint256 senderBalance = _balances[sender]; require(senderBalance >= amount, "ERC20: transfer amount exceeds balance"); unchecked { _balances[sender] = senderBalance - amount; } _balances[recipient] += amount; emit Transfer(sender, recipient, amount); _afterTokenTransfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. */ function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply += amount; _balances[account] += amount; emit Transfer(address(0), account, amount); _afterTokenTransfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); uint256 accountBalance = _balances[account]; require(accountBalance >= amount, "ERC20: burn amount exceeds balance"); unchecked { _balances[account] = accountBalance - amount; } _totalSupply -= amount; emit Transfer(account, address(0), amount); _afterTokenTransfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens. * * This internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve( address owner, address spender, uint256 amount ) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Hook that is called before any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * will be transferred to `to`. * - when `from` is zero, `amount` tokens will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address from, address to, uint256 amount ) internal virtual {} /** * @dev Hook that is called after any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * has been transferred to `to`. * - when `from` is zero, `amount` tokens have been minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens have been burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _afterTokenTransfer( address from, address to, uint256 amount ) internal virtual {} }
/** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * For a generic mechanism see {ERC20PresetMinterPauser}. * * TIP: For a detailed writeup see our guide * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * We have followed general OpenZeppelin Contracts guidelines: functions revert * instead returning `false` on failure. This behavior is nonetheless * conventional and does not conflict with the expectations of ERC20 * applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */
NatSpecMultiLine
name
function name() public view virtual override returns (string memory) { return _name; }
/** * @dev Returns the name of the token. */
NatSpecMultiLine
v0.8.9+commit.e5eed63a
None
ipfs://5f0cb9e21d86cd5adb7cff989d61c2776f890af786cc12aa518a3c4db9b3e293
{ "func_code_index": [ 776, 881 ] }
488
StarToken
@openzeppelin/contracts/token/ERC20/ERC20.sol
0x24eb24647786135352cbb14f888b23277f0014e7
Solidity
ERC20
contract ERC20 is Context, IERC20, IERC20Metadata { mapping(address => uint256) private _balances; mapping(address => mapping(address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; /** * @dev Sets the values for {name} and {symbol}. * * The default value of {decimals} is 18. To select a different value for * {decimals} you should overload it. * * All two of these values are immutable: they can only be set once during * construction. */ constructor(string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } /** * @dev Returns the name of the token. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5.05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the value {ERC20} uses, unless this function is * overridden; * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view virtual override returns (uint8) { return 18; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view virtual override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}. * * Requirements: * * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for ``sender``'s tokens of at least * `amount`. */ function transferFrom( address sender, address recipient, uint256 amount ) public virtual override returns (bool) { _transfer(sender, recipient, amount); uint256 currentAllowance = _allowances[sender][_msgSender()]; require(currentAllowance >= amount, "ERC20: transfer amount exceeds allowance"); unchecked { _approve(sender, _msgSender(), currentAllowance - amount); } return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { uint256 currentAllowance = _allowances[_msgSender()][spender]; require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero"); unchecked { _approve(_msgSender(), spender, currentAllowance - subtractedValue); } return true; } /** * @dev Moves `amount` of tokens from `sender` to `recipient`. * * This internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer( address sender, address recipient, uint256 amount ) internal virtual { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(sender, recipient, amount); uint256 senderBalance = _balances[sender]; require(senderBalance >= amount, "ERC20: transfer amount exceeds balance"); unchecked { _balances[sender] = senderBalance - amount; } _balances[recipient] += amount; emit Transfer(sender, recipient, amount); _afterTokenTransfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. */ function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply += amount; _balances[account] += amount; emit Transfer(address(0), account, amount); _afterTokenTransfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); uint256 accountBalance = _balances[account]; require(accountBalance >= amount, "ERC20: burn amount exceeds balance"); unchecked { _balances[account] = accountBalance - amount; } _totalSupply -= amount; emit Transfer(account, address(0), amount); _afterTokenTransfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens. * * This internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve( address owner, address spender, uint256 amount ) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Hook that is called before any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * will be transferred to `to`. * - when `from` is zero, `amount` tokens will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address from, address to, uint256 amount ) internal virtual {} /** * @dev Hook that is called after any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * has been transferred to `to`. * - when `from` is zero, `amount` tokens have been minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens have been burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _afterTokenTransfer( address from, address to, uint256 amount ) internal virtual {} }
/** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * For a generic mechanism see {ERC20PresetMinterPauser}. * * TIP: For a detailed writeup see our guide * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * We have followed general OpenZeppelin Contracts guidelines: functions revert * instead returning `false` on failure. This behavior is nonetheless * conventional and does not conflict with the expectations of ERC20 * applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */
NatSpecMultiLine
symbol
function symbol() public view virtual override returns (string memory) { return _symbol; }
/** * @dev Returns the symbol of the token, usually a shorter version of the * name. */
NatSpecMultiLine
v0.8.9+commit.e5eed63a
None
ipfs://5f0cb9e21d86cd5adb7cff989d61c2776f890af786cc12aa518a3c4db9b3e293
{ "func_code_index": [ 995, 1104 ] }
489
StarToken
@openzeppelin/contracts/token/ERC20/ERC20.sol
0x24eb24647786135352cbb14f888b23277f0014e7
Solidity
ERC20
contract ERC20 is Context, IERC20, IERC20Metadata { mapping(address => uint256) private _balances; mapping(address => mapping(address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; /** * @dev Sets the values for {name} and {symbol}. * * The default value of {decimals} is 18. To select a different value for * {decimals} you should overload it. * * All two of these values are immutable: they can only be set once during * construction. */ constructor(string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } /** * @dev Returns the name of the token. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5.05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the value {ERC20} uses, unless this function is * overridden; * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view virtual override returns (uint8) { return 18; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view virtual override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}. * * Requirements: * * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for ``sender``'s tokens of at least * `amount`. */ function transferFrom( address sender, address recipient, uint256 amount ) public virtual override returns (bool) { _transfer(sender, recipient, amount); uint256 currentAllowance = _allowances[sender][_msgSender()]; require(currentAllowance >= amount, "ERC20: transfer amount exceeds allowance"); unchecked { _approve(sender, _msgSender(), currentAllowance - amount); } return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { uint256 currentAllowance = _allowances[_msgSender()][spender]; require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero"); unchecked { _approve(_msgSender(), spender, currentAllowance - subtractedValue); } return true; } /** * @dev Moves `amount` of tokens from `sender` to `recipient`. * * This internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer( address sender, address recipient, uint256 amount ) internal virtual { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(sender, recipient, amount); uint256 senderBalance = _balances[sender]; require(senderBalance >= amount, "ERC20: transfer amount exceeds balance"); unchecked { _balances[sender] = senderBalance - amount; } _balances[recipient] += amount; emit Transfer(sender, recipient, amount); _afterTokenTransfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. */ function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply += amount; _balances[account] += amount; emit Transfer(address(0), account, amount); _afterTokenTransfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); uint256 accountBalance = _balances[account]; require(accountBalance >= amount, "ERC20: burn amount exceeds balance"); unchecked { _balances[account] = accountBalance - amount; } _totalSupply -= amount; emit Transfer(account, address(0), amount); _afterTokenTransfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens. * * This internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve( address owner, address spender, uint256 amount ) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Hook that is called before any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * will be transferred to `to`. * - when `from` is zero, `amount` tokens will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address from, address to, uint256 amount ) internal virtual {} /** * @dev Hook that is called after any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * has been transferred to `to`. * - when `from` is zero, `amount` tokens have been minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens have been burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _afterTokenTransfer( address from, address to, uint256 amount ) internal virtual {} }
/** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * For a generic mechanism see {ERC20PresetMinterPauser}. * * TIP: For a detailed writeup see our guide * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * We have followed general OpenZeppelin Contracts guidelines: functions revert * instead returning `false` on failure. This behavior is nonetheless * conventional and does not conflict with the expectations of ERC20 * applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */
NatSpecMultiLine
decimals
function decimals() public view virtual override returns (uint8) { return 18; }
/** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5.05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the value {ERC20} uses, unless this function is * overridden; * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */
NatSpecMultiLine
v0.8.9+commit.e5eed63a
None
ipfs://5f0cb9e21d86cd5adb7cff989d61c2776f890af786cc12aa518a3c4db9b3e293
{ "func_code_index": [ 1738, 1836 ] }
490
StarToken
@openzeppelin/contracts/token/ERC20/ERC20.sol
0x24eb24647786135352cbb14f888b23277f0014e7
Solidity
ERC20
contract ERC20 is Context, IERC20, IERC20Metadata { mapping(address => uint256) private _balances; mapping(address => mapping(address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; /** * @dev Sets the values for {name} and {symbol}. * * The default value of {decimals} is 18. To select a different value for * {decimals} you should overload it. * * All two of these values are immutable: they can only be set once during * construction. */ constructor(string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } /** * @dev Returns the name of the token. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5.05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the value {ERC20} uses, unless this function is * overridden; * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view virtual override returns (uint8) { return 18; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view virtual override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}. * * Requirements: * * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for ``sender``'s tokens of at least * `amount`. */ function transferFrom( address sender, address recipient, uint256 amount ) public virtual override returns (bool) { _transfer(sender, recipient, amount); uint256 currentAllowance = _allowances[sender][_msgSender()]; require(currentAllowance >= amount, "ERC20: transfer amount exceeds allowance"); unchecked { _approve(sender, _msgSender(), currentAllowance - amount); } return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { uint256 currentAllowance = _allowances[_msgSender()][spender]; require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero"); unchecked { _approve(_msgSender(), spender, currentAllowance - subtractedValue); } return true; } /** * @dev Moves `amount` of tokens from `sender` to `recipient`. * * This internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer( address sender, address recipient, uint256 amount ) internal virtual { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(sender, recipient, amount); uint256 senderBalance = _balances[sender]; require(senderBalance >= amount, "ERC20: transfer amount exceeds balance"); unchecked { _balances[sender] = senderBalance - amount; } _balances[recipient] += amount; emit Transfer(sender, recipient, amount); _afterTokenTransfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. */ function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply += amount; _balances[account] += amount; emit Transfer(address(0), account, amount); _afterTokenTransfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); uint256 accountBalance = _balances[account]; require(accountBalance >= amount, "ERC20: burn amount exceeds balance"); unchecked { _balances[account] = accountBalance - amount; } _totalSupply -= amount; emit Transfer(account, address(0), amount); _afterTokenTransfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens. * * This internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve( address owner, address spender, uint256 amount ) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Hook that is called before any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * will be transferred to `to`. * - when `from` is zero, `amount` tokens will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address from, address to, uint256 amount ) internal virtual {} /** * @dev Hook that is called after any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * has been transferred to `to`. * - when `from` is zero, `amount` tokens have been minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens have been burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _afterTokenTransfer( address from, address to, uint256 amount ) internal virtual {} }
/** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * For a generic mechanism see {ERC20PresetMinterPauser}. * * TIP: For a detailed writeup see our guide * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * We have followed general OpenZeppelin Contracts guidelines: functions revert * instead returning `false` on failure. This behavior is nonetheless * conventional and does not conflict with the expectations of ERC20 * applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */
NatSpecMultiLine
totalSupply
function totalSupply() public view virtual override returns (uint256) { return _totalSupply; }
/** * @dev See {IERC20-totalSupply}. */
NatSpecMultiLine
v0.8.9+commit.e5eed63a
None
ipfs://5f0cb9e21d86cd5adb7cff989d61c2776f890af786cc12aa518a3c4db9b3e293
{ "func_code_index": [ 1896, 2009 ] }
491
StarToken
@openzeppelin/contracts/token/ERC20/ERC20.sol
0x24eb24647786135352cbb14f888b23277f0014e7
Solidity
ERC20
contract ERC20 is Context, IERC20, IERC20Metadata { mapping(address => uint256) private _balances; mapping(address => mapping(address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; /** * @dev Sets the values for {name} and {symbol}. * * The default value of {decimals} is 18. To select a different value for * {decimals} you should overload it. * * All two of these values are immutable: they can only be set once during * construction. */ constructor(string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } /** * @dev Returns the name of the token. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5.05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the value {ERC20} uses, unless this function is * overridden; * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view virtual override returns (uint8) { return 18; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view virtual override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}. * * Requirements: * * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for ``sender``'s tokens of at least * `amount`. */ function transferFrom( address sender, address recipient, uint256 amount ) public virtual override returns (bool) { _transfer(sender, recipient, amount); uint256 currentAllowance = _allowances[sender][_msgSender()]; require(currentAllowance >= amount, "ERC20: transfer amount exceeds allowance"); unchecked { _approve(sender, _msgSender(), currentAllowance - amount); } return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { uint256 currentAllowance = _allowances[_msgSender()][spender]; require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero"); unchecked { _approve(_msgSender(), spender, currentAllowance - subtractedValue); } return true; } /** * @dev Moves `amount` of tokens from `sender` to `recipient`. * * This internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer( address sender, address recipient, uint256 amount ) internal virtual { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(sender, recipient, amount); uint256 senderBalance = _balances[sender]; require(senderBalance >= amount, "ERC20: transfer amount exceeds balance"); unchecked { _balances[sender] = senderBalance - amount; } _balances[recipient] += amount; emit Transfer(sender, recipient, amount); _afterTokenTransfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. */ function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply += amount; _balances[account] += amount; emit Transfer(address(0), account, amount); _afterTokenTransfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); uint256 accountBalance = _balances[account]; require(accountBalance >= amount, "ERC20: burn amount exceeds balance"); unchecked { _balances[account] = accountBalance - amount; } _totalSupply -= amount; emit Transfer(account, address(0), amount); _afterTokenTransfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens. * * This internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve( address owner, address spender, uint256 amount ) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Hook that is called before any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * will be transferred to `to`. * - when `from` is zero, `amount` tokens will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address from, address to, uint256 amount ) internal virtual {} /** * @dev Hook that is called after any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * has been transferred to `to`. * - when `from` is zero, `amount` tokens have been minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens have been burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _afterTokenTransfer( address from, address to, uint256 amount ) internal virtual {} }
/** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * For a generic mechanism see {ERC20PresetMinterPauser}. * * TIP: For a detailed writeup see our guide * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * We have followed general OpenZeppelin Contracts guidelines: functions revert * instead returning `false` on failure. This behavior is nonetheless * conventional and does not conflict with the expectations of ERC20 * applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */
NatSpecMultiLine
balanceOf
function balanceOf(address account) public view virtual override returns (uint256) { return _balances[account]; }
/** * @dev See {IERC20-balanceOf}. */
NatSpecMultiLine
v0.8.9+commit.e5eed63a
None
ipfs://5f0cb9e21d86cd5adb7cff989d61c2776f890af786cc12aa518a3c4db9b3e293
{ "func_code_index": [ 2067, 2199 ] }
492
StarToken
@openzeppelin/contracts/token/ERC20/ERC20.sol
0x24eb24647786135352cbb14f888b23277f0014e7
Solidity
ERC20
contract ERC20 is Context, IERC20, IERC20Metadata { mapping(address => uint256) private _balances; mapping(address => mapping(address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; /** * @dev Sets the values for {name} and {symbol}. * * The default value of {decimals} is 18. To select a different value for * {decimals} you should overload it. * * All two of these values are immutable: they can only be set once during * construction. */ constructor(string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } /** * @dev Returns the name of the token. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5.05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the value {ERC20} uses, unless this function is * overridden; * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view virtual override returns (uint8) { return 18; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view virtual override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}. * * Requirements: * * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for ``sender``'s tokens of at least * `amount`. */ function transferFrom( address sender, address recipient, uint256 amount ) public virtual override returns (bool) { _transfer(sender, recipient, amount); uint256 currentAllowance = _allowances[sender][_msgSender()]; require(currentAllowance >= amount, "ERC20: transfer amount exceeds allowance"); unchecked { _approve(sender, _msgSender(), currentAllowance - amount); } return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { uint256 currentAllowance = _allowances[_msgSender()][spender]; require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero"); unchecked { _approve(_msgSender(), spender, currentAllowance - subtractedValue); } return true; } /** * @dev Moves `amount` of tokens from `sender` to `recipient`. * * This internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer( address sender, address recipient, uint256 amount ) internal virtual { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(sender, recipient, amount); uint256 senderBalance = _balances[sender]; require(senderBalance >= amount, "ERC20: transfer amount exceeds balance"); unchecked { _balances[sender] = senderBalance - amount; } _balances[recipient] += amount; emit Transfer(sender, recipient, amount); _afterTokenTransfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. */ function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply += amount; _balances[account] += amount; emit Transfer(address(0), account, amount); _afterTokenTransfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); uint256 accountBalance = _balances[account]; require(accountBalance >= amount, "ERC20: burn amount exceeds balance"); unchecked { _balances[account] = accountBalance - amount; } _totalSupply -= amount; emit Transfer(account, address(0), amount); _afterTokenTransfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens. * * This internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve( address owner, address spender, uint256 amount ) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Hook that is called before any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * will be transferred to `to`. * - when `from` is zero, `amount` tokens will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address from, address to, uint256 amount ) internal virtual {} /** * @dev Hook that is called after any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * has been transferred to `to`. * - when `from` is zero, `amount` tokens have been minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens have been burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _afterTokenTransfer( address from, address to, uint256 amount ) internal virtual {} }
/** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * For a generic mechanism see {ERC20PresetMinterPauser}. * * TIP: For a detailed writeup see our guide * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * We have followed general OpenZeppelin Contracts guidelines: functions revert * instead returning `false` on failure. This behavior is nonetheless * conventional and does not conflict with the expectations of ERC20 * applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */
NatSpecMultiLine
transfer
function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; }
/** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */
NatSpecMultiLine
v0.8.9+commit.e5eed63a
None
ipfs://5f0cb9e21d86cd5adb7cff989d61c2776f890af786cc12aa518a3c4db9b3e293
{ "func_code_index": [ 2407, 2587 ] }
493
StarToken
@openzeppelin/contracts/token/ERC20/ERC20.sol
0x24eb24647786135352cbb14f888b23277f0014e7
Solidity
ERC20
contract ERC20 is Context, IERC20, IERC20Metadata { mapping(address => uint256) private _balances; mapping(address => mapping(address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; /** * @dev Sets the values for {name} and {symbol}. * * The default value of {decimals} is 18. To select a different value for * {decimals} you should overload it. * * All two of these values are immutable: they can only be set once during * construction. */ constructor(string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } /** * @dev Returns the name of the token. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5.05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the value {ERC20} uses, unless this function is * overridden; * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view virtual override returns (uint8) { return 18; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view virtual override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}. * * Requirements: * * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for ``sender``'s tokens of at least * `amount`. */ function transferFrom( address sender, address recipient, uint256 amount ) public virtual override returns (bool) { _transfer(sender, recipient, amount); uint256 currentAllowance = _allowances[sender][_msgSender()]; require(currentAllowance >= amount, "ERC20: transfer amount exceeds allowance"); unchecked { _approve(sender, _msgSender(), currentAllowance - amount); } return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { uint256 currentAllowance = _allowances[_msgSender()][spender]; require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero"); unchecked { _approve(_msgSender(), spender, currentAllowance - subtractedValue); } return true; } /** * @dev Moves `amount` of tokens from `sender` to `recipient`. * * This internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer( address sender, address recipient, uint256 amount ) internal virtual { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(sender, recipient, amount); uint256 senderBalance = _balances[sender]; require(senderBalance >= amount, "ERC20: transfer amount exceeds balance"); unchecked { _balances[sender] = senderBalance - amount; } _balances[recipient] += amount; emit Transfer(sender, recipient, amount); _afterTokenTransfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. */ function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply += amount; _balances[account] += amount; emit Transfer(address(0), account, amount); _afterTokenTransfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); uint256 accountBalance = _balances[account]; require(accountBalance >= amount, "ERC20: burn amount exceeds balance"); unchecked { _balances[account] = accountBalance - amount; } _totalSupply -= amount; emit Transfer(account, address(0), amount); _afterTokenTransfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens. * * This internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve( address owner, address spender, uint256 amount ) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Hook that is called before any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * will be transferred to `to`. * - when `from` is zero, `amount` tokens will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address from, address to, uint256 amount ) internal virtual {} /** * @dev Hook that is called after any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * has been transferred to `to`. * - when `from` is zero, `amount` tokens have been minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens have been burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _afterTokenTransfer( address from, address to, uint256 amount ) internal virtual {} }
/** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * For a generic mechanism see {ERC20PresetMinterPauser}. * * TIP: For a detailed writeup see our guide * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * We have followed general OpenZeppelin Contracts guidelines: functions revert * instead returning `false` on failure. This behavior is nonetheless * conventional and does not conflict with the expectations of ERC20 * applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */
NatSpecMultiLine
allowance
function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; }
/** * @dev See {IERC20-allowance}. */
NatSpecMultiLine
v0.8.9+commit.e5eed63a
None
ipfs://5f0cb9e21d86cd5adb7cff989d61c2776f890af786cc12aa518a3c4db9b3e293
{ "func_code_index": [ 2645, 2801 ] }
494
StarToken
@openzeppelin/contracts/token/ERC20/ERC20.sol
0x24eb24647786135352cbb14f888b23277f0014e7
Solidity
ERC20
contract ERC20 is Context, IERC20, IERC20Metadata { mapping(address => uint256) private _balances; mapping(address => mapping(address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; /** * @dev Sets the values for {name} and {symbol}. * * The default value of {decimals} is 18. To select a different value for * {decimals} you should overload it. * * All two of these values are immutable: they can only be set once during * construction. */ constructor(string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } /** * @dev Returns the name of the token. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5.05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the value {ERC20} uses, unless this function is * overridden; * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view virtual override returns (uint8) { return 18; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view virtual override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}. * * Requirements: * * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for ``sender``'s tokens of at least * `amount`. */ function transferFrom( address sender, address recipient, uint256 amount ) public virtual override returns (bool) { _transfer(sender, recipient, amount); uint256 currentAllowance = _allowances[sender][_msgSender()]; require(currentAllowance >= amount, "ERC20: transfer amount exceeds allowance"); unchecked { _approve(sender, _msgSender(), currentAllowance - amount); } return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { uint256 currentAllowance = _allowances[_msgSender()][spender]; require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero"); unchecked { _approve(_msgSender(), spender, currentAllowance - subtractedValue); } return true; } /** * @dev Moves `amount` of tokens from `sender` to `recipient`. * * This internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer( address sender, address recipient, uint256 amount ) internal virtual { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(sender, recipient, amount); uint256 senderBalance = _balances[sender]; require(senderBalance >= amount, "ERC20: transfer amount exceeds balance"); unchecked { _balances[sender] = senderBalance - amount; } _balances[recipient] += amount; emit Transfer(sender, recipient, amount); _afterTokenTransfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. */ function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply += amount; _balances[account] += amount; emit Transfer(address(0), account, amount); _afterTokenTransfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); uint256 accountBalance = _balances[account]; require(accountBalance >= amount, "ERC20: burn amount exceeds balance"); unchecked { _balances[account] = accountBalance - amount; } _totalSupply -= amount; emit Transfer(account, address(0), amount); _afterTokenTransfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens. * * This internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve( address owner, address spender, uint256 amount ) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Hook that is called before any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * will be transferred to `to`. * - when `from` is zero, `amount` tokens will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address from, address to, uint256 amount ) internal virtual {} /** * @dev Hook that is called after any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * has been transferred to `to`. * - when `from` is zero, `amount` tokens have been minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens have been burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _afterTokenTransfer( address from, address to, uint256 amount ) internal virtual {} }
/** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * For a generic mechanism see {ERC20PresetMinterPauser}. * * TIP: For a detailed writeup see our guide * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * We have followed general OpenZeppelin Contracts guidelines: functions revert * instead returning `false` on failure. This behavior is nonetheless * conventional and does not conflict with the expectations of ERC20 * applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */
NatSpecMultiLine
approve
function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), spender, amount); return true; }
/** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */
NatSpecMultiLine
v0.8.9+commit.e5eed63a
None
ipfs://5f0cb9e21d86cd5adb7cff989d61c2776f890af786cc12aa518a3c4db9b3e293
{ "func_code_index": [ 2943, 3117 ] }
495
StarToken
@openzeppelin/contracts/token/ERC20/ERC20.sol
0x24eb24647786135352cbb14f888b23277f0014e7
Solidity
ERC20
contract ERC20 is Context, IERC20, IERC20Metadata { mapping(address => uint256) private _balances; mapping(address => mapping(address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; /** * @dev Sets the values for {name} and {symbol}. * * The default value of {decimals} is 18. To select a different value for * {decimals} you should overload it. * * All two of these values are immutable: they can only be set once during * construction. */ constructor(string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } /** * @dev Returns the name of the token. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5.05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the value {ERC20} uses, unless this function is * overridden; * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view virtual override returns (uint8) { return 18; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view virtual override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}. * * Requirements: * * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for ``sender``'s tokens of at least * `amount`. */ function transferFrom( address sender, address recipient, uint256 amount ) public virtual override returns (bool) { _transfer(sender, recipient, amount); uint256 currentAllowance = _allowances[sender][_msgSender()]; require(currentAllowance >= amount, "ERC20: transfer amount exceeds allowance"); unchecked { _approve(sender, _msgSender(), currentAllowance - amount); } return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { uint256 currentAllowance = _allowances[_msgSender()][spender]; require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero"); unchecked { _approve(_msgSender(), spender, currentAllowance - subtractedValue); } return true; } /** * @dev Moves `amount` of tokens from `sender` to `recipient`. * * This internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer( address sender, address recipient, uint256 amount ) internal virtual { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(sender, recipient, amount); uint256 senderBalance = _balances[sender]; require(senderBalance >= amount, "ERC20: transfer amount exceeds balance"); unchecked { _balances[sender] = senderBalance - amount; } _balances[recipient] += amount; emit Transfer(sender, recipient, amount); _afterTokenTransfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. */ function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply += amount; _balances[account] += amount; emit Transfer(address(0), account, amount); _afterTokenTransfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); uint256 accountBalance = _balances[account]; require(accountBalance >= amount, "ERC20: burn amount exceeds balance"); unchecked { _balances[account] = accountBalance - amount; } _totalSupply -= amount; emit Transfer(account, address(0), amount); _afterTokenTransfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens. * * This internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve( address owner, address spender, uint256 amount ) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Hook that is called before any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * will be transferred to `to`. * - when `from` is zero, `amount` tokens will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address from, address to, uint256 amount ) internal virtual {} /** * @dev Hook that is called after any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * has been transferred to `to`. * - when `from` is zero, `amount` tokens have been minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens have been burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _afterTokenTransfer( address from, address to, uint256 amount ) internal virtual {} }
/** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * For a generic mechanism see {ERC20PresetMinterPauser}. * * TIP: For a detailed writeup see our guide * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * We have followed general OpenZeppelin Contracts guidelines: functions revert * instead returning `false` on failure. This behavior is nonetheless * conventional and does not conflict with the expectations of ERC20 * applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */
NatSpecMultiLine
transferFrom
function transferFrom( address sender, address recipient, uint256 amount ) public virtual override returns (bool) { _transfer(sender, recipient, amount); uint256 currentAllowance = _allowances[sender][_msgSender()]; require(currentAllowance >= amount, "ERC20: transfer amount exceeds allowance"); unchecked { _approve(sender, _msgSender(), currentAllowance - amount); } return true; }
/** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}. * * Requirements: * * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for ``sender``'s tokens of at least * `amount`. */
NatSpecMultiLine
v0.8.9+commit.e5eed63a
None
ipfs://5f0cb9e21d86cd5adb7cff989d61c2776f890af786cc12aa518a3c4db9b3e293
{ "func_code_index": [ 3594, 4079 ] }
496
StarToken
@openzeppelin/contracts/token/ERC20/ERC20.sol
0x24eb24647786135352cbb14f888b23277f0014e7
Solidity
ERC20
contract ERC20 is Context, IERC20, IERC20Metadata { mapping(address => uint256) private _balances; mapping(address => mapping(address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; /** * @dev Sets the values for {name} and {symbol}. * * The default value of {decimals} is 18. To select a different value for * {decimals} you should overload it. * * All two of these values are immutable: they can only be set once during * construction. */ constructor(string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } /** * @dev Returns the name of the token. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5.05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the value {ERC20} uses, unless this function is * overridden; * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view virtual override returns (uint8) { return 18; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view virtual override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}. * * Requirements: * * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for ``sender``'s tokens of at least * `amount`. */ function transferFrom( address sender, address recipient, uint256 amount ) public virtual override returns (bool) { _transfer(sender, recipient, amount); uint256 currentAllowance = _allowances[sender][_msgSender()]; require(currentAllowance >= amount, "ERC20: transfer amount exceeds allowance"); unchecked { _approve(sender, _msgSender(), currentAllowance - amount); } return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { uint256 currentAllowance = _allowances[_msgSender()][spender]; require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero"); unchecked { _approve(_msgSender(), spender, currentAllowance - subtractedValue); } return true; } /** * @dev Moves `amount` of tokens from `sender` to `recipient`. * * This internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer( address sender, address recipient, uint256 amount ) internal virtual { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(sender, recipient, amount); uint256 senderBalance = _balances[sender]; require(senderBalance >= amount, "ERC20: transfer amount exceeds balance"); unchecked { _balances[sender] = senderBalance - amount; } _balances[recipient] += amount; emit Transfer(sender, recipient, amount); _afterTokenTransfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. */ function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply += amount; _balances[account] += amount; emit Transfer(address(0), account, amount); _afterTokenTransfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); uint256 accountBalance = _balances[account]; require(accountBalance >= amount, "ERC20: burn amount exceeds balance"); unchecked { _balances[account] = accountBalance - amount; } _totalSupply -= amount; emit Transfer(account, address(0), amount); _afterTokenTransfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens. * * This internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve( address owner, address spender, uint256 amount ) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Hook that is called before any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * will be transferred to `to`. * - when `from` is zero, `amount` tokens will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address from, address to, uint256 amount ) internal virtual {} /** * @dev Hook that is called after any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * has been transferred to `to`. * - when `from` is zero, `amount` tokens have been minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens have been burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _afterTokenTransfer( address from, address to, uint256 amount ) internal virtual {} }
/** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * For a generic mechanism see {ERC20PresetMinterPauser}. * * TIP: For a detailed writeup see our guide * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * We have followed general OpenZeppelin Contracts guidelines: functions revert * instead returning `false` on failure. This behavior is nonetheless * conventional and does not conflict with the expectations of ERC20 * applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */
NatSpecMultiLine
increaseAllowance
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue); return true; }
/** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */
NatSpecMultiLine
v0.8.9+commit.e5eed63a
None
ipfs://5f0cb9e21d86cd5adb7cff989d61c2776f890af786cc12aa518a3c4db9b3e293
{ "func_code_index": [ 4483, 4703 ] }
497
StarToken
@openzeppelin/contracts/token/ERC20/ERC20.sol
0x24eb24647786135352cbb14f888b23277f0014e7
Solidity
ERC20
contract ERC20 is Context, IERC20, IERC20Metadata { mapping(address => uint256) private _balances; mapping(address => mapping(address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; /** * @dev Sets the values for {name} and {symbol}. * * The default value of {decimals} is 18. To select a different value for * {decimals} you should overload it. * * All two of these values are immutable: they can only be set once during * construction. */ constructor(string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } /** * @dev Returns the name of the token. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5.05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the value {ERC20} uses, unless this function is * overridden; * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view virtual override returns (uint8) { return 18; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view virtual override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}. * * Requirements: * * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for ``sender``'s tokens of at least * `amount`. */ function transferFrom( address sender, address recipient, uint256 amount ) public virtual override returns (bool) { _transfer(sender, recipient, amount); uint256 currentAllowance = _allowances[sender][_msgSender()]; require(currentAllowance >= amount, "ERC20: transfer amount exceeds allowance"); unchecked { _approve(sender, _msgSender(), currentAllowance - amount); } return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { uint256 currentAllowance = _allowances[_msgSender()][spender]; require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero"); unchecked { _approve(_msgSender(), spender, currentAllowance - subtractedValue); } return true; } /** * @dev Moves `amount` of tokens from `sender` to `recipient`. * * This internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer( address sender, address recipient, uint256 amount ) internal virtual { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(sender, recipient, amount); uint256 senderBalance = _balances[sender]; require(senderBalance >= amount, "ERC20: transfer amount exceeds balance"); unchecked { _balances[sender] = senderBalance - amount; } _balances[recipient] += amount; emit Transfer(sender, recipient, amount); _afterTokenTransfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. */ function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply += amount; _balances[account] += amount; emit Transfer(address(0), account, amount); _afterTokenTransfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); uint256 accountBalance = _balances[account]; require(accountBalance >= amount, "ERC20: burn amount exceeds balance"); unchecked { _balances[account] = accountBalance - amount; } _totalSupply -= amount; emit Transfer(account, address(0), amount); _afterTokenTransfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens. * * This internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve( address owner, address spender, uint256 amount ) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Hook that is called before any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * will be transferred to `to`. * - when `from` is zero, `amount` tokens will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address from, address to, uint256 amount ) internal virtual {} /** * @dev Hook that is called after any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * has been transferred to `to`. * - when `from` is zero, `amount` tokens have been minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens have been burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _afterTokenTransfer( address from, address to, uint256 amount ) internal virtual {} }
/** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * For a generic mechanism see {ERC20PresetMinterPauser}. * * TIP: For a detailed writeup see our guide * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * We have followed general OpenZeppelin Contracts guidelines: functions revert * instead returning `false` on failure. This behavior is nonetheless * conventional and does not conflict with the expectations of ERC20 * applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */
NatSpecMultiLine
decreaseAllowance
function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { uint256 currentAllowance = _allowances[_msgSender()][spender]; require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero"); unchecked { _approve(_msgSender(), spender, currentAllowance - subtractedValue); } return true; }
/** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */
NatSpecMultiLine
v0.8.9+commit.e5eed63a
None
ipfs://5f0cb9e21d86cd5adb7cff989d61c2776f890af786cc12aa518a3c4db9b3e293
{ "func_code_index": [ 5201, 5607 ] }
498
StarToken
@openzeppelin/contracts/token/ERC20/ERC20.sol
0x24eb24647786135352cbb14f888b23277f0014e7
Solidity
ERC20
contract ERC20 is Context, IERC20, IERC20Metadata { mapping(address => uint256) private _balances; mapping(address => mapping(address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; /** * @dev Sets the values for {name} and {symbol}. * * The default value of {decimals} is 18. To select a different value for * {decimals} you should overload it. * * All two of these values are immutable: they can only be set once during * construction. */ constructor(string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } /** * @dev Returns the name of the token. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5.05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the value {ERC20} uses, unless this function is * overridden; * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view virtual override returns (uint8) { return 18; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view virtual override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}. * * Requirements: * * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for ``sender``'s tokens of at least * `amount`. */ function transferFrom( address sender, address recipient, uint256 amount ) public virtual override returns (bool) { _transfer(sender, recipient, amount); uint256 currentAllowance = _allowances[sender][_msgSender()]; require(currentAllowance >= amount, "ERC20: transfer amount exceeds allowance"); unchecked { _approve(sender, _msgSender(), currentAllowance - amount); } return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { uint256 currentAllowance = _allowances[_msgSender()][spender]; require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero"); unchecked { _approve(_msgSender(), spender, currentAllowance - subtractedValue); } return true; } /** * @dev Moves `amount` of tokens from `sender` to `recipient`. * * This internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer( address sender, address recipient, uint256 amount ) internal virtual { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(sender, recipient, amount); uint256 senderBalance = _balances[sender]; require(senderBalance >= amount, "ERC20: transfer amount exceeds balance"); unchecked { _balances[sender] = senderBalance - amount; } _balances[recipient] += amount; emit Transfer(sender, recipient, amount); _afterTokenTransfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. */ function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply += amount; _balances[account] += amount; emit Transfer(address(0), account, amount); _afterTokenTransfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); uint256 accountBalance = _balances[account]; require(accountBalance >= amount, "ERC20: burn amount exceeds balance"); unchecked { _balances[account] = accountBalance - amount; } _totalSupply -= amount; emit Transfer(account, address(0), amount); _afterTokenTransfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens. * * This internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve( address owner, address spender, uint256 amount ) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Hook that is called before any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * will be transferred to `to`. * - when `from` is zero, `amount` tokens will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address from, address to, uint256 amount ) internal virtual {} /** * @dev Hook that is called after any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * has been transferred to `to`. * - when `from` is zero, `amount` tokens have been minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens have been burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _afterTokenTransfer( address from, address to, uint256 amount ) internal virtual {} }
/** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * For a generic mechanism see {ERC20PresetMinterPauser}. * * TIP: For a detailed writeup see our guide * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * We have followed general OpenZeppelin Contracts guidelines: functions revert * instead returning `false` on failure. This behavior is nonetheless * conventional and does not conflict with the expectations of ERC20 * applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */
NatSpecMultiLine
_transfer
function _transfer( address sender, address recipient, uint256 amount ) internal virtual { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(sender, recipient, amount); uint256 senderBalance = _balances[sender]; require(senderBalance >= amount, "ERC20: transfer amount exceeds balance"); unchecked { _balances[sender] = senderBalance - amount; } _balances[recipient] += amount; emit Transfer(sender, recipient, amount); _afterTokenTransfer(sender, recipient, amount); }
/** * @dev Moves `amount` of tokens from `sender` to `recipient`. * * This internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */
NatSpecMultiLine
v0.8.9+commit.e5eed63a
None
ipfs://5f0cb9e21d86cd5adb7cff989d61c2776f890af786cc12aa518a3c4db9b3e293
{ "func_code_index": [ 6092, 6818 ] }
499
StarToken
@openzeppelin/contracts/token/ERC20/ERC20.sol
0x24eb24647786135352cbb14f888b23277f0014e7
Solidity
ERC20
contract ERC20 is Context, IERC20, IERC20Metadata { mapping(address => uint256) private _balances; mapping(address => mapping(address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; /** * @dev Sets the values for {name} and {symbol}. * * The default value of {decimals} is 18. To select a different value for * {decimals} you should overload it. * * All two of these values are immutable: they can only be set once during * construction. */ constructor(string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } /** * @dev Returns the name of the token. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5.05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the value {ERC20} uses, unless this function is * overridden; * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view virtual override returns (uint8) { return 18; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view virtual override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}. * * Requirements: * * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for ``sender``'s tokens of at least * `amount`. */ function transferFrom( address sender, address recipient, uint256 amount ) public virtual override returns (bool) { _transfer(sender, recipient, amount); uint256 currentAllowance = _allowances[sender][_msgSender()]; require(currentAllowance >= amount, "ERC20: transfer amount exceeds allowance"); unchecked { _approve(sender, _msgSender(), currentAllowance - amount); } return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { uint256 currentAllowance = _allowances[_msgSender()][spender]; require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero"); unchecked { _approve(_msgSender(), spender, currentAllowance - subtractedValue); } return true; } /** * @dev Moves `amount` of tokens from `sender` to `recipient`. * * This internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer( address sender, address recipient, uint256 amount ) internal virtual { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(sender, recipient, amount); uint256 senderBalance = _balances[sender]; require(senderBalance >= amount, "ERC20: transfer amount exceeds balance"); unchecked { _balances[sender] = senderBalance - amount; } _balances[recipient] += amount; emit Transfer(sender, recipient, amount); _afterTokenTransfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. */ function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply += amount; _balances[account] += amount; emit Transfer(address(0), account, amount); _afterTokenTransfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); uint256 accountBalance = _balances[account]; require(accountBalance >= amount, "ERC20: burn amount exceeds balance"); unchecked { _balances[account] = accountBalance - amount; } _totalSupply -= amount; emit Transfer(account, address(0), amount); _afterTokenTransfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens. * * This internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve( address owner, address spender, uint256 amount ) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Hook that is called before any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * will be transferred to `to`. * - when `from` is zero, `amount` tokens will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address from, address to, uint256 amount ) internal virtual {} /** * @dev Hook that is called after any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * has been transferred to `to`. * - when `from` is zero, `amount` tokens have been minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens have been burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _afterTokenTransfer( address from, address to, uint256 amount ) internal virtual {} }
/** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * For a generic mechanism see {ERC20PresetMinterPauser}. * * TIP: For a detailed writeup see our guide * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * We have followed general OpenZeppelin Contracts guidelines: functions revert * instead returning `false` on failure. This behavior is nonetheless * conventional and does not conflict with the expectations of ERC20 * applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */
NatSpecMultiLine
_mint
function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply += amount; _balances[account] += amount; emit Transfer(address(0), account, amount); _afterTokenTransfer(address(0), account, amount); }
/** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. */
NatSpecMultiLine
v0.8.9+commit.e5eed63a
None
ipfs://5f0cb9e21d86cd5adb7cff989d61c2776f890af786cc12aa518a3c4db9b3e293
{ "func_code_index": [ 7100, 7504 ] }
500
StarToken
@openzeppelin/contracts/token/ERC20/ERC20.sol
0x24eb24647786135352cbb14f888b23277f0014e7
Solidity
ERC20
contract ERC20 is Context, IERC20, IERC20Metadata { mapping(address => uint256) private _balances; mapping(address => mapping(address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; /** * @dev Sets the values for {name} and {symbol}. * * The default value of {decimals} is 18. To select a different value for * {decimals} you should overload it. * * All two of these values are immutable: they can only be set once during * construction. */ constructor(string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } /** * @dev Returns the name of the token. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5.05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the value {ERC20} uses, unless this function is * overridden; * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view virtual override returns (uint8) { return 18; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view virtual override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}. * * Requirements: * * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for ``sender``'s tokens of at least * `amount`. */ function transferFrom( address sender, address recipient, uint256 amount ) public virtual override returns (bool) { _transfer(sender, recipient, amount); uint256 currentAllowance = _allowances[sender][_msgSender()]; require(currentAllowance >= amount, "ERC20: transfer amount exceeds allowance"); unchecked { _approve(sender, _msgSender(), currentAllowance - amount); } return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { uint256 currentAllowance = _allowances[_msgSender()][spender]; require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero"); unchecked { _approve(_msgSender(), spender, currentAllowance - subtractedValue); } return true; } /** * @dev Moves `amount` of tokens from `sender` to `recipient`. * * This internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer( address sender, address recipient, uint256 amount ) internal virtual { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(sender, recipient, amount); uint256 senderBalance = _balances[sender]; require(senderBalance >= amount, "ERC20: transfer amount exceeds balance"); unchecked { _balances[sender] = senderBalance - amount; } _balances[recipient] += amount; emit Transfer(sender, recipient, amount); _afterTokenTransfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. */ function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply += amount; _balances[account] += amount; emit Transfer(address(0), account, amount); _afterTokenTransfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); uint256 accountBalance = _balances[account]; require(accountBalance >= amount, "ERC20: burn amount exceeds balance"); unchecked { _balances[account] = accountBalance - amount; } _totalSupply -= amount; emit Transfer(account, address(0), amount); _afterTokenTransfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens. * * This internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve( address owner, address spender, uint256 amount ) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Hook that is called before any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * will be transferred to `to`. * - when `from` is zero, `amount` tokens will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address from, address to, uint256 amount ) internal virtual {} /** * @dev Hook that is called after any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * has been transferred to `to`. * - when `from` is zero, `amount` tokens have been minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens have been burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _afterTokenTransfer( address from, address to, uint256 amount ) internal virtual {} }
/** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * For a generic mechanism see {ERC20PresetMinterPauser}. * * TIP: For a detailed writeup see our guide * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * We have followed general OpenZeppelin Contracts guidelines: functions revert * instead returning `false` on failure. This behavior is nonetheless * conventional and does not conflict with the expectations of ERC20 * applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */
NatSpecMultiLine
_burn
function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); uint256 accountBalance = _balances[account]; require(accountBalance >= amount, "ERC20: burn amount exceeds balance"); unchecked { _balances[account] = accountBalance - amount; } _totalSupply -= amount; emit Transfer(account, address(0), amount); _afterTokenTransfer(account, address(0), amount); }
/** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */
NatSpecMultiLine
v0.8.9+commit.e5eed63a
None
ipfs://5f0cb9e21d86cd5adb7cff989d61c2776f890af786cc12aa518a3c4db9b3e293
{ "func_code_index": [ 7832, 8416 ] }
501
StarToken
@openzeppelin/contracts/token/ERC20/ERC20.sol
0x24eb24647786135352cbb14f888b23277f0014e7
Solidity
ERC20
contract ERC20 is Context, IERC20, IERC20Metadata { mapping(address => uint256) private _balances; mapping(address => mapping(address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; /** * @dev Sets the values for {name} and {symbol}. * * The default value of {decimals} is 18. To select a different value for * {decimals} you should overload it. * * All two of these values are immutable: they can only be set once during * construction. */ constructor(string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } /** * @dev Returns the name of the token. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5.05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the value {ERC20} uses, unless this function is * overridden; * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view virtual override returns (uint8) { return 18; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view virtual override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}. * * Requirements: * * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for ``sender``'s tokens of at least * `amount`. */ function transferFrom( address sender, address recipient, uint256 amount ) public virtual override returns (bool) { _transfer(sender, recipient, amount); uint256 currentAllowance = _allowances[sender][_msgSender()]; require(currentAllowance >= amount, "ERC20: transfer amount exceeds allowance"); unchecked { _approve(sender, _msgSender(), currentAllowance - amount); } return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { uint256 currentAllowance = _allowances[_msgSender()][spender]; require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero"); unchecked { _approve(_msgSender(), spender, currentAllowance - subtractedValue); } return true; } /** * @dev Moves `amount` of tokens from `sender` to `recipient`. * * This internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer( address sender, address recipient, uint256 amount ) internal virtual { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(sender, recipient, amount); uint256 senderBalance = _balances[sender]; require(senderBalance >= amount, "ERC20: transfer amount exceeds balance"); unchecked { _balances[sender] = senderBalance - amount; } _balances[recipient] += amount; emit Transfer(sender, recipient, amount); _afterTokenTransfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. */ function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply += amount; _balances[account] += amount; emit Transfer(address(0), account, amount); _afterTokenTransfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); uint256 accountBalance = _balances[account]; require(accountBalance >= amount, "ERC20: burn amount exceeds balance"); unchecked { _balances[account] = accountBalance - amount; } _totalSupply -= amount; emit Transfer(account, address(0), amount); _afterTokenTransfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens. * * This internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve( address owner, address spender, uint256 amount ) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Hook that is called before any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * will be transferred to `to`. * - when `from` is zero, `amount` tokens will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address from, address to, uint256 amount ) internal virtual {} /** * @dev Hook that is called after any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * has been transferred to `to`. * - when `from` is zero, `amount` tokens have been minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens have been burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _afterTokenTransfer( address from, address to, uint256 amount ) internal virtual {} }
/** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * For a generic mechanism see {ERC20PresetMinterPauser}. * * TIP: For a detailed writeup see our guide * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * We have followed general OpenZeppelin Contracts guidelines: functions revert * instead returning `false` on failure. This behavior is nonetheless * conventional and does not conflict with the expectations of ERC20 * applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */
NatSpecMultiLine
_approve
function _approve( address owner, address spender, uint256 amount ) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); }
/** * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens. * * This internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */
NatSpecMultiLine
v0.8.9+commit.e5eed63a
None
ipfs://5f0cb9e21d86cd5adb7cff989d61c2776f890af786cc12aa518a3c4db9b3e293
{ "func_code_index": [ 8849, 9234 ] }
502
StarToken
@openzeppelin/contracts/token/ERC20/ERC20.sol
0x24eb24647786135352cbb14f888b23277f0014e7
Solidity
ERC20
contract ERC20 is Context, IERC20, IERC20Metadata { mapping(address => uint256) private _balances; mapping(address => mapping(address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; /** * @dev Sets the values for {name} and {symbol}. * * The default value of {decimals} is 18. To select a different value for * {decimals} you should overload it. * * All two of these values are immutable: they can only be set once during * construction. */ constructor(string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } /** * @dev Returns the name of the token. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5.05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the value {ERC20} uses, unless this function is * overridden; * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view virtual override returns (uint8) { return 18; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view virtual override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}. * * Requirements: * * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for ``sender``'s tokens of at least * `amount`. */ function transferFrom( address sender, address recipient, uint256 amount ) public virtual override returns (bool) { _transfer(sender, recipient, amount); uint256 currentAllowance = _allowances[sender][_msgSender()]; require(currentAllowance >= amount, "ERC20: transfer amount exceeds allowance"); unchecked { _approve(sender, _msgSender(), currentAllowance - amount); } return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { uint256 currentAllowance = _allowances[_msgSender()][spender]; require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero"); unchecked { _approve(_msgSender(), spender, currentAllowance - subtractedValue); } return true; } /** * @dev Moves `amount` of tokens from `sender` to `recipient`. * * This internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer( address sender, address recipient, uint256 amount ) internal virtual { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(sender, recipient, amount); uint256 senderBalance = _balances[sender]; require(senderBalance >= amount, "ERC20: transfer amount exceeds balance"); unchecked { _balances[sender] = senderBalance - amount; } _balances[recipient] += amount; emit Transfer(sender, recipient, amount); _afterTokenTransfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. */ function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply += amount; _balances[account] += amount; emit Transfer(address(0), account, amount); _afterTokenTransfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); uint256 accountBalance = _balances[account]; require(accountBalance >= amount, "ERC20: burn amount exceeds balance"); unchecked { _balances[account] = accountBalance - amount; } _totalSupply -= amount; emit Transfer(account, address(0), amount); _afterTokenTransfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens. * * This internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve( address owner, address spender, uint256 amount ) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Hook that is called before any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * will be transferred to `to`. * - when `from` is zero, `amount` tokens will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address from, address to, uint256 amount ) internal virtual {} /** * @dev Hook that is called after any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * has been transferred to `to`. * - when `from` is zero, `amount` tokens have been minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens have been burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _afterTokenTransfer( address from, address to, uint256 amount ) internal virtual {} }
/** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * For a generic mechanism see {ERC20PresetMinterPauser}. * * TIP: For a detailed writeup see our guide * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * We have followed general OpenZeppelin Contracts guidelines: functions revert * instead returning `false` on failure. This behavior is nonetheless * conventional and does not conflict with the expectations of ERC20 * applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */
NatSpecMultiLine
_beforeTokenTransfer
function _beforeTokenTransfer( address from, address to, uint256 amount ) internal virtual {}
/** * @dev Hook that is called before any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * will be transferred to `to`. * - when `from` is zero, `amount` tokens will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */
NatSpecMultiLine
v0.8.9+commit.e5eed63a
None
ipfs://5f0cb9e21d86cd5adb7cff989d61c2776f890af786cc12aa518a3c4db9b3e293
{ "func_code_index": [ 9829, 9959 ] }
503
StarToken
@openzeppelin/contracts/token/ERC20/ERC20.sol
0x24eb24647786135352cbb14f888b23277f0014e7
Solidity
ERC20
contract ERC20 is Context, IERC20, IERC20Metadata { mapping(address => uint256) private _balances; mapping(address => mapping(address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; /** * @dev Sets the values for {name} and {symbol}. * * The default value of {decimals} is 18. To select a different value for * {decimals} you should overload it. * * All two of these values are immutable: they can only be set once during * construction. */ constructor(string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } /** * @dev Returns the name of the token. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5.05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the value {ERC20} uses, unless this function is * overridden; * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view virtual override returns (uint8) { return 18; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view virtual override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}. * * Requirements: * * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for ``sender``'s tokens of at least * `amount`. */ function transferFrom( address sender, address recipient, uint256 amount ) public virtual override returns (bool) { _transfer(sender, recipient, amount); uint256 currentAllowance = _allowances[sender][_msgSender()]; require(currentAllowance >= amount, "ERC20: transfer amount exceeds allowance"); unchecked { _approve(sender, _msgSender(), currentAllowance - amount); } return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { uint256 currentAllowance = _allowances[_msgSender()][spender]; require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero"); unchecked { _approve(_msgSender(), spender, currentAllowance - subtractedValue); } return true; } /** * @dev Moves `amount` of tokens from `sender` to `recipient`. * * This internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer( address sender, address recipient, uint256 amount ) internal virtual { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(sender, recipient, amount); uint256 senderBalance = _balances[sender]; require(senderBalance >= amount, "ERC20: transfer amount exceeds balance"); unchecked { _balances[sender] = senderBalance - amount; } _balances[recipient] += amount; emit Transfer(sender, recipient, amount); _afterTokenTransfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. */ function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply += amount; _balances[account] += amount; emit Transfer(address(0), account, amount); _afterTokenTransfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); uint256 accountBalance = _balances[account]; require(accountBalance >= amount, "ERC20: burn amount exceeds balance"); unchecked { _balances[account] = accountBalance - amount; } _totalSupply -= amount; emit Transfer(account, address(0), amount); _afterTokenTransfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens. * * This internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve( address owner, address spender, uint256 amount ) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Hook that is called before any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * will be transferred to `to`. * - when `from` is zero, `amount` tokens will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address from, address to, uint256 amount ) internal virtual {} /** * @dev Hook that is called after any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * has been transferred to `to`. * - when `from` is zero, `amount` tokens have been minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens have been burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _afterTokenTransfer( address from, address to, uint256 amount ) internal virtual {} }
/** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * For a generic mechanism see {ERC20PresetMinterPauser}. * * TIP: For a detailed writeup see our guide * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * We have followed general OpenZeppelin Contracts guidelines: functions revert * instead returning `false` on failure. This behavior is nonetheless * conventional and does not conflict with the expectations of ERC20 * applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */
NatSpecMultiLine
_afterTokenTransfer
function _afterTokenTransfer( address from, address to, uint256 amount ) internal virtual {}
/** * @dev Hook that is called after any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * has been transferred to `to`. * - when `from` is zero, `amount` tokens have been minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens have been burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */
NatSpecMultiLine
v0.8.9+commit.e5eed63a
None
ipfs://5f0cb9e21d86cd5adb7cff989d61c2776f890af786cc12aa518a3c4db9b3e293
{ "func_code_index": [ 10558, 10687 ] }
504
FixedROwnableToken
@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol
0x32a5bf1df6e98aa9b3705534e8959b29894d3156
Solidity
IERC20Metadata
interface IERC20Metadata is IERC20 { /** * @dev Returns the name of the token. */ function name() external view returns (string memory); /** * @dev Returns the symbol of the token. */ function symbol() external view returns (string memory); /** * @dev Returns the decimals places of the token. */ function decimals() external view returns (uint8); }
/** * @dev Interface for the optional metadata functions from the ERC20 standard. * * _Available since v4.1._ */
NatSpecMultiLine
name
function name() external view returns (string memory);
/** * @dev Returns the name of the token. */
NatSpecMultiLine
v0.8.4+commit.c7e474f2
MIT
{ "func_code_index": [ 96, 154 ] }
505
FixedROwnableToken
@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol
0x32a5bf1df6e98aa9b3705534e8959b29894d3156
Solidity
IERC20Metadata
interface IERC20Metadata is IERC20 { /** * @dev Returns the name of the token. */ function name() external view returns (string memory); /** * @dev Returns the symbol of the token. */ function symbol() external view returns (string memory); /** * @dev Returns the decimals places of the token. */ function decimals() external view returns (uint8); }
/** * @dev Interface for the optional metadata functions from the ERC20 standard. * * _Available since v4.1._ */
NatSpecMultiLine
symbol
function symbol() external view returns (string memory);
/** * @dev Returns the symbol of the token. */
NatSpecMultiLine
v0.8.4+commit.c7e474f2
MIT
{ "func_code_index": [ 217, 277 ] }
506