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
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
MetaCityGame | MetaCityGame.sol | 0xafcc9ec6652972d84708183e2d4cc5783270c549 | 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 | BSD-3-Clause | ipfs://5dd2aac3ed36df599508f3134c0e37fd8230190881b91d5aac7412c679a35eb4 | {
"func_code_index": [
3721,
3922
]
} | 2,507 |
||
MetaCityGame | MetaCityGame.sol | 0xafcc9ec6652972d84708183e2d4cc5783270c549 | 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 | BSD-3-Clause | ipfs://5dd2aac3ed36df599508f3134c0e37fd8230190881b91d5aac7412c679a35eb4 | {
"func_code_index": [
4292,
4523
]
} | 2,508 |
||
MetaCityGame | MetaCityGame.sol | 0xafcc9ec6652972d84708183e2d4cc5783270c549 | 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 | BSD-3-Clause | ipfs://5dd2aac3ed36df599508f3134c0e37fd8230190881b91d5aac7412c679a35eb4 | {
"func_code_index": [
4774,
5095
]
} | 2,509 |
||
MetaCityGame | MetaCityGame.sol | 0xafcc9ec6652972d84708183e2d4cc5783270c549 | 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.s
*
* 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 | BSD-3-Clause | ipfs://5dd2aac3ed36df599508f3134c0e37fd8230190881b91d5aac7412c679a35eb4 | {
"func_code_index": [
94,
154
]
} | 2,510 |
||
MetaCityGame | MetaCityGame.sol | 0xafcc9ec6652972d84708183e2d4cc5783270c549 | 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.s
*
* 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 | BSD-3-Clause | ipfs://5dd2aac3ed36df599508f3134c0e37fd8230190881b91d5aac7412c679a35eb4 | {
"func_code_index": [
237,
310
]
} | 2,511 |
||
MetaCityGame | MetaCityGame.sol | 0xafcc9ec6652972d84708183e2d4cc5783270c549 | 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.s
*
* 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.s
*
* Emits a {Transfer} event.
*/ | NatSpecMultiLine | v0.6.12+commit.27d51765 | BSD-3-Clause | ipfs://5dd2aac3ed36df599508f3134c0e37fd8230190881b91d5aac7412c679a35eb4 | {
"func_code_index": [
535,
617
]
} | 2,512 |
||
MetaCityGame | MetaCityGame.sol | 0xafcc9ec6652972d84708183e2d4cc5783270c549 | 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.s
*
* 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 | BSD-3-Clause | ipfs://5dd2aac3ed36df599508f3134c0e37fd8230190881b91d5aac7412c679a35eb4 | {
"func_code_index": [
896,
984
]
} | 2,513 |
||
MetaCityGame | MetaCityGame.sol | 0xafcc9ec6652972d84708183e2d4cc5783270c549 | 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.s
*
* 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 | BSD-3-Clause | ipfs://5dd2aac3ed36df599508f3134c0e37fd8230190881b91d5aac7412c679a35eb4 | {
"func_code_index": [
1648,
1727
]
} | 2,514 |
||
MetaCityGame | MetaCityGame.sol | 0xafcc9ec6652972d84708183e2d4cc5783270c549 | 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.s
*
* 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 | BSD-3-Clause | ipfs://5dd2aac3ed36df599508f3134c0e37fd8230190881b91d5aac7412c679a35eb4 | {
"func_code_index": [
2040,
2142
]
} | 2,515 |
||
MetaCityGame | MetaCityGame.sol | 0xafcc9ec6652972d84708183e2d4cc5783270c549 | 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 | BSD-3-Clause | ipfs://5dd2aac3ed36df599508f3134c0e37fd8230190881b91d5aac7412c679a35eb4 | {
"func_code_index": [
259,
445
]
} | 2,516 |
||
MetaCityGame | MetaCityGame.sol | 0xafcc9ec6652972d84708183e2d4cc5783270c549 | 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 | BSD-3-Clause | ipfs://5dd2aac3ed36df599508f3134c0e37fd8230190881b91d5aac7412c679a35eb4 | {
"func_code_index": [
723,
864
]
} | 2,517 |
||
MetaCityGame | MetaCityGame.sol | 0xafcc9ec6652972d84708183e2d4cc5783270c549 | 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 | BSD-3-Clause | ipfs://5dd2aac3ed36df599508f3134c0e37fd8230190881b91d5aac7412c679a35eb4 | {
"func_code_index": [
1162,
1359
]
} | 2,518 |
||
MetaCityGame | MetaCityGame.sol | 0xafcc9ec6652972d84708183e2d4cc5783270c549 | 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 | BSD-3-Clause | ipfs://5dd2aac3ed36df599508f3134c0e37fd8230190881b91d5aac7412c679a35eb4 | {
"func_code_index": [
1613,
2089
]
} | 2,519 |
||
MetaCityGame | MetaCityGame.sol | 0xafcc9ec6652972d84708183e2d4cc5783270c549 | 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 | BSD-3-Clause | ipfs://5dd2aac3ed36df599508f3134c0e37fd8230190881b91d5aac7412c679a35eb4 | {
"func_code_index": [
2560,
2697
]
} | 2,520 |
||
MetaCityGame | MetaCityGame.sol | 0xafcc9ec6652972d84708183e2d4cc5783270c549 | 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 | BSD-3-Clause | ipfs://5dd2aac3ed36df599508f3134c0e37fd8230190881b91d5aac7412c679a35eb4 | {
"func_code_index": [
3188,
3471
]
} | 2,521 |
||
MetaCityGame | MetaCityGame.sol | 0xafcc9ec6652972d84708183e2d4cc5783270c549 | 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 | BSD-3-Clause | ipfs://5dd2aac3ed36df599508f3134c0e37fd8230190881b91d5aac7412c679a35eb4 | {
"func_code_index": [
3931,
4066
]
} | 2,522 |
||
MetaCityGame | MetaCityGame.sol | 0xafcc9ec6652972d84708183e2d4cc5783270c549 | 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 | BSD-3-Clause | ipfs://5dd2aac3ed36df599508f3134c0e37fd8230190881b91d5aac7412c679a35eb4 | {
"func_code_index": [
4546,
4717
]
} | 2,523 |
||
MetaCityGame | MetaCityGame.sol | 0xafcc9ec6652972d84708183e2d4cc5783270c549 | 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 pure returns (address) {
return address(0);
}
/**
* @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));
}
/**
* @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 pure returns (address) {
return address(0);
}
| /**
* @dev Returns the address of the current owner.
*/ | NatSpecMultiLine | v0.6.12+commit.27d51765 | BSD-3-Clause | ipfs://5dd2aac3ed36df599508f3134c0e37fd8230190881b91d5aac7412c679a35eb4 | {
"func_code_index": [
497,
585
]
} | 2,524 |
||
MetaCityGame | MetaCityGame.sol | 0xafcc9ec6652972d84708183e2d4cc5783270c549 | 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 pure returns (address) {
return address(0);
}
/**
* @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));
}
/**
* @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));
}
| /**
* @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 | BSD-3-Clause | ipfs://5dd2aac3ed36df599508f3134c0e37fd8230190881b91d5aac7412c679a35eb4 | {
"func_code_index": [
1143,
1266
]
} | 2,525 |
||
MetaCityGame | MetaCityGame.sol | 0xafcc9ec6652972d84708183e2d4cc5783270c549 | 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 pure returns (address) {
return address(0);
}
/**
* @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));
}
/**
* @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 | BSD-3-Clause | ipfs://5dd2aac3ed36df599508f3134c0e37fd8230190881b91d5aac7412c679a35eb4 | {
"func_code_index": [
1416,
1665
]
} | 2,526 |
||
ENSMigrationSubdomainRegistrar | @ensdomains/subdomain-registrar/contracts/EthRegistrarSubdomainRegistrar.sol | 0xe65d8aaf34cb91087d1598e0a15b582f57f217d9 | Solidity | EthRegistrarSubdomainRegistrar | contract EthRegistrarSubdomainRegistrar is AbstractSubdomainRegistrar {
struct Domain {
string name;
address payable owner;
uint price;
uint referralFeePPM;
}
mapping (bytes32 => Domain) domains;
constructor(ENS ens) AbstractSubdomainRegistrar(ens) public { }
/**
* @dev owner returns the address of the account that controls a domain.
* Initially this is a null address. If the name has been
* transferred to this contract, then the internal mapping is consulted
* to determine who controls it. If the owner is not set,
* the owner of the domain in the Registrar is returned.
* @param label The label hash of the deed to check.
* @return The address owning the deed.
*/
function owner(bytes32 label) public view returns (address) {
if (domains[label].owner != address(0x0)) {
return domains[label].owner;
}
return BaseRegistrar(registrar).ownerOf(uint256(label));
}
/**
* @dev Transfers internal control of a name to a new account. Does not update
* ENS.
* @param name The name to transfer.
* @param newOwner The address of the new owner.
*/
function transfer(string memory name, address payable newOwner) public owner_only(keccak256(bytes(name))) {
bytes32 label = keccak256(bytes(name));
emit OwnerChanged(label, domains[label].owner, newOwner);
domains[label].owner = newOwner;
}
/**
* @dev Configures a domain, optionally transferring it to a new owner.
* @param name The name to configure.
* @param price The price in wei to charge for subdomain registrations.
* @param referralFeePPM The referral fee to offer, in parts per million.
* @param _owner The address to assign ownership of this domain to.
* @param _transfer The address to set as the transfer address for the name
* when the permanent registrar is replaced. Can only be set to a non-zero
* value once.
*/
function configureDomainFor(string memory name, uint price, uint referralFeePPM, address payable _owner, address _transfer) public owner_only(keccak256(bytes(name))) {
bytes32 label = keccak256(bytes(name));
Domain storage domain = domains[label];
if (BaseRegistrar(registrar).ownerOf(uint256(label)) != address(this)) {
BaseRegistrar(registrar).transferFrom(msg.sender, address(this), uint256(label));
BaseRegistrar(registrar).reclaim(uint256(label), address(this));
}
if (domain.owner != _owner) {
domain.owner = _owner;
}
if (keccak256(bytes(domain.name)) != label) {
// New listing
domain.name = name;
}
domain.price = price;
domain.referralFeePPM = referralFeePPM;
emit DomainConfigured(label);
}
/**
* @dev Unlists a domain
* May only be called by the owner.
* @param name The name of the domain to unlist.
*/
function unlistDomain(string memory name) public owner_only(keccak256(bytes(name))) {
bytes32 label = keccak256(bytes(name));
Domain storage domain = domains[label];
emit DomainUnlisted(label);
domain.name = '';
domain.price = 0;
domain.referralFeePPM = 0;
}
/**
* @dev Returns information about a subdomain.
* @param label The label hash for the domain.
* @param subdomain The label for the subdomain.
* @return domain The name of the domain, or an empty string if the subdomain
* is unavailable.
* @return price The price to register a subdomain, in wei.
* @return rent The rent to retain a subdomain, in wei per second.
* @return referralFeePPM The referral fee for the dapp, in ppm.
*/
function query(bytes32 label, string calldata subdomain) external view returns (string memory domain, uint price, uint rent, uint referralFeePPM) {
bytes32 node = keccak256(abi.encodePacked(TLD_NODE, label));
bytes32 subnode = keccak256(abi.encodePacked(node, keccak256(bytes(subdomain))));
if (ens.owner(subnode) != address(0x0)) {
return ('', 0, 0, 0);
}
Domain storage data = domains[label];
return (data.name, data.price, 0, data.referralFeePPM);
}
/**
* @dev Registers a subdomain.
* @param label The label hash of the domain to register a subdomain of.
* @param subdomain The desired subdomain label.
* @param _subdomainOwner The account that should own the newly configured subdomain.
* @param referrer The address of the account to receive the referral fee.
*/
function register(bytes32 label, string calldata subdomain, address _subdomainOwner, address payable referrer, address resolver) external not_stopped payable {
address subdomainOwner = _subdomainOwner;
bytes32 domainNode = keccak256(abi.encodePacked(TLD_NODE, label));
bytes32 subdomainLabel = keccak256(bytes(subdomain));
// Subdomain must not be registered already.
require(ens.owner(keccak256(abi.encodePacked(domainNode, subdomainLabel))) == address(0));
Domain storage domain = domains[label];
// Domain must be available for registration
require(keccak256(bytes(domain.name)) == label);
// User must have paid enough
require(msg.value >= domain.price);
// Send any extra back
if (msg.value > domain.price) {
msg.sender.transfer(msg.value - domain.price);
}
// Send any referral fee
uint256 total = domain.price;
if (domain.referralFeePPM > 0 && referrer != address(0x0) && referrer != domain.owner) {
uint256 referralFee = (domain.price * domain.referralFeePPM) / 1000000;
referrer.transfer(referralFee);
total -= referralFee;
}
// Send the registration fee
if (total > 0) {
domain.owner.transfer(total);
}
// Register the domain
if (subdomainOwner == address(0x0)) {
subdomainOwner = msg.sender;
}
doRegistration(domainNode, subdomainLabel, subdomainOwner, Resolver(resolver));
emit NewRegistration(label, subdomain, subdomainOwner, referrer, domain.price);
}
function rentDue(bytes32 label, string calldata subdomain) external view returns (uint timestamp) {
return 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF;
}
/**
* @dev Migrates the domain to a new registrar.
* @param name The name of the domain to migrate.
*/
function migrate(string memory name) public owner_only(keccak256(bytes(name))) {
require(stopped);
require(migration != address(0x0));
bytes32 label = keccak256(bytes(name));
Domain storage domain = domains[label];
BaseRegistrar(registrar).approve(migration, uint256(label));
EthRegistrarSubdomainRegistrar(migration).configureDomainFor(
domain.name,
domain.price,
domain.referralFeePPM,
domain.owner,
address(0x0)
);
delete domains[label];
emit DomainTransferred(label, name);
}
function payRent(bytes32 label, string calldata subdomain) external payable {
revert();
}
} | /**
* @dev Implements an ENS registrar that sells subdomains on behalf of their owners.
*
* Users may register a subdomain by calling `register` with the name of the domain
* they wish to register under, and the label hash of the subdomain they want to
* register. They must also specify the new owner of the domain, and the referrer,
* who is paid an optional finder's fee. The registrar then configures a simple
* default resolver, which resolves `addr` lookups to the new owner, and sets
* the `owner` account as the owner of the subdomain in ENS.
*
* New domains may be added by calling `configureDomain`, then transferring
* ownership in the ENS registry to this contract. Ownership in the contract
* may be transferred using `transfer`, and a domain may be unlisted for sale
* using `unlistDomain`. There is (deliberately) no way to recover ownership
* in ENS once the name is transferred to this registrar.
*
* Critically, this contract does not check one key property of a listed domain:
*
* - Is the name UTS46 normalised?
*
* User applications MUST check these two elements for each domain before
* offering them to users for registration.
*
* Applications should additionally check that the domains they are offering to
* register are controlled by this registrar, since calls to `register` will
* fail if this is not the case.
*/ | NatSpecMultiLine | owner | function owner(bytes32 label) public view returns (address) {
if (domains[label].owner != address(0x0)) {
return domains[label].owner;
}
return BaseRegistrar(registrar).ownerOf(uint256(label));
}
| /**
* @dev owner returns the address of the account that controls a domain.
* Initially this is a null address. If the name has been
* transferred to this contract, then the internal mapping is consulted
* to determine who controls it. If the owner is not set,
* the owner of the domain in the Registrar is returned.
* @param label The label hash of the deed to check.
* @return The address owning the deed.
*/ | NatSpecMultiLine | v0.5.16+commit.9c3226ce | None | bzzr://8751e27803ad5386d933139faf690ecb1e80c3045ffede7816138b0531f8d76b | {
"func_code_index": [
809,
1056
]
} | 2,527 |
ENSMigrationSubdomainRegistrar | @ensdomains/subdomain-registrar/contracts/EthRegistrarSubdomainRegistrar.sol | 0xe65d8aaf34cb91087d1598e0a15b582f57f217d9 | Solidity | EthRegistrarSubdomainRegistrar | contract EthRegistrarSubdomainRegistrar is AbstractSubdomainRegistrar {
struct Domain {
string name;
address payable owner;
uint price;
uint referralFeePPM;
}
mapping (bytes32 => Domain) domains;
constructor(ENS ens) AbstractSubdomainRegistrar(ens) public { }
/**
* @dev owner returns the address of the account that controls a domain.
* Initially this is a null address. If the name has been
* transferred to this contract, then the internal mapping is consulted
* to determine who controls it. If the owner is not set,
* the owner of the domain in the Registrar is returned.
* @param label The label hash of the deed to check.
* @return The address owning the deed.
*/
function owner(bytes32 label) public view returns (address) {
if (domains[label].owner != address(0x0)) {
return domains[label].owner;
}
return BaseRegistrar(registrar).ownerOf(uint256(label));
}
/**
* @dev Transfers internal control of a name to a new account. Does not update
* ENS.
* @param name The name to transfer.
* @param newOwner The address of the new owner.
*/
function transfer(string memory name, address payable newOwner) public owner_only(keccak256(bytes(name))) {
bytes32 label = keccak256(bytes(name));
emit OwnerChanged(label, domains[label].owner, newOwner);
domains[label].owner = newOwner;
}
/**
* @dev Configures a domain, optionally transferring it to a new owner.
* @param name The name to configure.
* @param price The price in wei to charge for subdomain registrations.
* @param referralFeePPM The referral fee to offer, in parts per million.
* @param _owner The address to assign ownership of this domain to.
* @param _transfer The address to set as the transfer address for the name
* when the permanent registrar is replaced. Can only be set to a non-zero
* value once.
*/
function configureDomainFor(string memory name, uint price, uint referralFeePPM, address payable _owner, address _transfer) public owner_only(keccak256(bytes(name))) {
bytes32 label = keccak256(bytes(name));
Domain storage domain = domains[label];
if (BaseRegistrar(registrar).ownerOf(uint256(label)) != address(this)) {
BaseRegistrar(registrar).transferFrom(msg.sender, address(this), uint256(label));
BaseRegistrar(registrar).reclaim(uint256(label), address(this));
}
if (domain.owner != _owner) {
domain.owner = _owner;
}
if (keccak256(bytes(domain.name)) != label) {
// New listing
domain.name = name;
}
domain.price = price;
domain.referralFeePPM = referralFeePPM;
emit DomainConfigured(label);
}
/**
* @dev Unlists a domain
* May only be called by the owner.
* @param name The name of the domain to unlist.
*/
function unlistDomain(string memory name) public owner_only(keccak256(bytes(name))) {
bytes32 label = keccak256(bytes(name));
Domain storage domain = domains[label];
emit DomainUnlisted(label);
domain.name = '';
domain.price = 0;
domain.referralFeePPM = 0;
}
/**
* @dev Returns information about a subdomain.
* @param label The label hash for the domain.
* @param subdomain The label for the subdomain.
* @return domain The name of the domain, or an empty string if the subdomain
* is unavailable.
* @return price The price to register a subdomain, in wei.
* @return rent The rent to retain a subdomain, in wei per second.
* @return referralFeePPM The referral fee for the dapp, in ppm.
*/
function query(bytes32 label, string calldata subdomain) external view returns (string memory domain, uint price, uint rent, uint referralFeePPM) {
bytes32 node = keccak256(abi.encodePacked(TLD_NODE, label));
bytes32 subnode = keccak256(abi.encodePacked(node, keccak256(bytes(subdomain))));
if (ens.owner(subnode) != address(0x0)) {
return ('', 0, 0, 0);
}
Domain storage data = domains[label];
return (data.name, data.price, 0, data.referralFeePPM);
}
/**
* @dev Registers a subdomain.
* @param label The label hash of the domain to register a subdomain of.
* @param subdomain The desired subdomain label.
* @param _subdomainOwner The account that should own the newly configured subdomain.
* @param referrer The address of the account to receive the referral fee.
*/
function register(bytes32 label, string calldata subdomain, address _subdomainOwner, address payable referrer, address resolver) external not_stopped payable {
address subdomainOwner = _subdomainOwner;
bytes32 domainNode = keccak256(abi.encodePacked(TLD_NODE, label));
bytes32 subdomainLabel = keccak256(bytes(subdomain));
// Subdomain must not be registered already.
require(ens.owner(keccak256(abi.encodePacked(domainNode, subdomainLabel))) == address(0));
Domain storage domain = domains[label];
// Domain must be available for registration
require(keccak256(bytes(domain.name)) == label);
// User must have paid enough
require(msg.value >= domain.price);
// Send any extra back
if (msg.value > domain.price) {
msg.sender.transfer(msg.value - domain.price);
}
// Send any referral fee
uint256 total = domain.price;
if (domain.referralFeePPM > 0 && referrer != address(0x0) && referrer != domain.owner) {
uint256 referralFee = (domain.price * domain.referralFeePPM) / 1000000;
referrer.transfer(referralFee);
total -= referralFee;
}
// Send the registration fee
if (total > 0) {
domain.owner.transfer(total);
}
// Register the domain
if (subdomainOwner == address(0x0)) {
subdomainOwner = msg.sender;
}
doRegistration(domainNode, subdomainLabel, subdomainOwner, Resolver(resolver));
emit NewRegistration(label, subdomain, subdomainOwner, referrer, domain.price);
}
function rentDue(bytes32 label, string calldata subdomain) external view returns (uint timestamp) {
return 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF;
}
/**
* @dev Migrates the domain to a new registrar.
* @param name The name of the domain to migrate.
*/
function migrate(string memory name) public owner_only(keccak256(bytes(name))) {
require(stopped);
require(migration != address(0x0));
bytes32 label = keccak256(bytes(name));
Domain storage domain = domains[label];
BaseRegistrar(registrar).approve(migration, uint256(label));
EthRegistrarSubdomainRegistrar(migration).configureDomainFor(
domain.name,
domain.price,
domain.referralFeePPM,
domain.owner,
address(0x0)
);
delete domains[label];
emit DomainTransferred(label, name);
}
function payRent(bytes32 label, string calldata subdomain) external payable {
revert();
}
} | /**
* @dev Implements an ENS registrar that sells subdomains on behalf of their owners.
*
* Users may register a subdomain by calling `register` with the name of the domain
* they wish to register under, and the label hash of the subdomain they want to
* register. They must also specify the new owner of the domain, and the referrer,
* who is paid an optional finder's fee. The registrar then configures a simple
* default resolver, which resolves `addr` lookups to the new owner, and sets
* the `owner` account as the owner of the subdomain in ENS.
*
* New domains may be added by calling `configureDomain`, then transferring
* ownership in the ENS registry to this contract. Ownership in the contract
* may be transferred using `transfer`, and a domain may be unlisted for sale
* using `unlistDomain`. There is (deliberately) no way to recover ownership
* in ENS once the name is transferred to this registrar.
*
* Critically, this contract does not check one key property of a listed domain:
*
* - Is the name UTS46 normalised?
*
* User applications MUST check these two elements for each domain before
* offering them to users for registration.
*
* Applications should additionally check that the domains they are offering to
* register are controlled by this registrar, since calls to `register` will
* fail if this is not the case.
*/ | NatSpecMultiLine | transfer | function transfer(string memory name, address payable newOwner) public owner_only(keccak256(bytes(name))) {
bytes32 label = keccak256(bytes(name));
emit OwnerChanged(label, domains[label].owner, newOwner);
domains[label].owner = newOwner;
}
| /**
* @dev Transfers internal control of a name to a new account. Does not update
* ENS.
* @param name The name to transfer.
* @param newOwner The address of the new owner.
*/ | NatSpecMultiLine | v0.5.16+commit.9c3226ce | None | bzzr://8751e27803ad5386d933139faf690ecb1e80c3045ffede7816138b0531f8d76b | {
"func_code_index": [
1275,
1552
]
} | 2,528 |
ENSMigrationSubdomainRegistrar | @ensdomains/subdomain-registrar/contracts/EthRegistrarSubdomainRegistrar.sol | 0xe65d8aaf34cb91087d1598e0a15b582f57f217d9 | Solidity | EthRegistrarSubdomainRegistrar | contract EthRegistrarSubdomainRegistrar is AbstractSubdomainRegistrar {
struct Domain {
string name;
address payable owner;
uint price;
uint referralFeePPM;
}
mapping (bytes32 => Domain) domains;
constructor(ENS ens) AbstractSubdomainRegistrar(ens) public { }
/**
* @dev owner returns the address of the account that controls a domain.
* Initially this is a null address. If the name has been
* transferred to this contract, then the internal mapping is consulted
* to determine who controls it. If the owner is not set,
* the owner of the domain in the Registrar is returned.
* @param label The label hash of the deed to check.
* @return The address owning the deed.
*/
function owner(bytes32 label) public view returns (address) {
if (domains[label].owner != address(0x0)) {
return domains[label].owner;
}
return BaseRegistrar(registrar).ownerOf(uint256(label));
}
/**
* @dev Transfers internal control of a name to a new account. Does not update
* ENS.
* @param name The name to transfer.
* @param newOwner The address of the new owner.
*/
function transfer(string memory name, address payable newOwner) public owner_only(keccak256(bytes(name))) {
bytes32 label = keccak256(bytes(name));
emit OwnerChanged(label, domains[label].owner, newOwner);
domains[label].owner = newOwner;
}
/**
* @dev Configures a domain, optionally transferring it to a new owner.
* @param name The name to configure.
* @param price The price in wei to charge for subdomain registrations.
* @param referralFeePPM The referral fee to offer, in parts per million.
* @param _owner The address to assign ownership of this domain to.
* @param _transfer The address to set as the transfer address for the name
* when the permanent registrar is replaced. Can only be set to a non-zero
* value once.
*/
function configureDomainFor(string memory name, uint price, uint referralFeePPM, address payable _owner, address _transfer) public owner_only(keccak256(bytes(name))) {
bytes32 label = keccak256(bytes(name));
Domain storage domain = domains[label];
if (BaseRegistrar(registrar).ownerOf(uint256(label)) != address(this)) {
BaseRegistrar(registrar).transferFrom(msg.sender, address(this), uint256(label));
BaseRegistrar(registrar).reclaim(uint256(label), address(this));
}
if (domain.owner != _owner) {
domain.owner = _owner;
}
if (keccak256(bytes(domain.name)) != label) {
// New listing
domain.name = name;
}
domain.price = price;
domain.referralFeePPM = referralFeePPM;
emit DomainConfigured(label);
}
/**
* @dev Unlists a domain
* May only be called by the owner.
* @param name The name of the domain to unlist.
*/
function unlistDomain(string memory name) public owner_only(keccak256(bytes(name))) {
bytes32 label = keccak256(bytes(name));
Domain storage domain = domains[label];
emit DomainUnlisted(label);
domain.name = '';
domain.price = 0;
domain.referralFeePPM = 0;
}
/**
* @dev Returns information about a subdomain.
* @param label The label hash for the domain.
* @param subdomain The label for the subdomain.
* @return domain The name of the domain, or an empty string if the subdomain
* is unavailable.
* @return price The price to register a subdomain, in wei.
* @return rent The rent to retain a subdomain, in wei per second.
* @return referralFeePPM The referral fee for the dapp, in ppm.
*/
function query(bytes32 label, string calldata subdomain) external view returns (string memory domain, uint price, uint rent, uint referralFeePPM) {
bytes32 node = keccak256(abi.encodePacked(TLD_NODE, label));
bytes32 subnode = keccak256(abi.encodePacked(node, keccak256(bytes(subdomain))));
if (ens.owner(subnode) != address(0x0)) {
return ('', 0, 0, 0);
}
Domain storage data = domains[label];
return (data.name, data.price, 0, data.referralFeePPM);
}
/**
* @dev Registers a subdomain.
* @param label The label hash of the domain to register a subdomain of.
* @param subdomain The desired subdomain label.
* @param _subdomainOwner The account that should own the newly configured subdomain.
* @param referrer The address of the account to receive the referral fee.
*/
function register(bytes32 label, string calldata subdomain, address _subdomainOwner, address payable referrer, address resolver) external not_stopped payable {
address subdomainOwner = _subdomainOwner;
bytes32 domainNode = keccak256(abi.encodePacked(TLD_NODE, label));
bytes32 subdomainLabel = keccak256(bytes(subdomain));
// Subdomain must not be registered already.
require(ens.owner(keccak256(abi.encodePacked(domainNode, subdomainLabel))) == address(0));
Domain storage domain = domains[label];
// Domain must be available for registration
require(keccak256(bytes(domain.name)) == label);
// User must have paid enough
require(msg.value >= domain.price);
// Send any extra back
if (msg.value > domain.price) {
msg.sender.transfer(msg.value - domain.price);
}
// Send any referral fee
uint256 total = domain.price;
if (domain.referralFeePPM > 0 && referrer != address(0x0) && referrer != domain.owner) {
uint256 referralFee = (domain.price * domain.referralFeePPM) / 1000000;
referrer.transfer(referralFee);
total -= referralFee;
}
// Send the registration fee
if (total > 0) {
domain.owner.transfer(total);
}
// Register the domain
if (subdomainOwner == address(0x0)) {
subdomainOwner = msg.sender;
}
doRegistration(domainNode, subdomainLabel, subdomainOwner, Resolver(resolver));
emit NewRegistration(label, subdomain, subdomainOwner, referrer, domain.price);
}
function rentDue(bytes32 label, string calldata subdomain) external view returns (uint timestamp) {
return 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF;
}
/**
* @dev Migrates the domain to a new registrar.
* @param name The name of the domain to migrate.
*/
function migrate(string memory name) public owner_only(keccak256(bytes(name))) {
require(stopped);
require(migration != address(0x0));
bytes32 label = keccak256(bytes(name));
Domain storage domain = domains[label];
BaseRegistrar(registrar).approve(migration, uint256(label));
EthRegistrarSubdomainRegistrar(migration).configureDomainFor(
domain.name,
domain.price,
domain.referralFeePPM,
domain.owner,
address(0x0)
);
delete domains[label];
emit DomainTransferred(label, name);
}
function payRent(bytes32 label, string calldata subdomain) external payable {
revert();
}
} | /**
* @dev Implements an ENS registrar that sells subdomains on behalf of their owners.
*
* Users may register a subdomain by calling `register` with the name of the domain
* they wish to register under, and the label hash of the subdomain they want to
* register. They must also specify the new owner of the domain, and the referrer,
* who is paid an optional finder's fee. The registrar then configures a simple
* default resolver, which resolves `addr` lookups to the new owner, and sets
* the `owner` account as the owner of the subdomain in ENS.
*
* New domains may be added by calling `configureDomain`, then transferring
* ownership in the ENS registry to this contract. Ownership in the contract
* may be transferred using `transfer`, and a domain may be unlisted for sale
* using `unlistDomain`. There is (deliberately) no way to recover ownership
* in ENS once the name is transferred to this registrar.
*
* Critically, this contract does not check one key property of a listed domain:
*
* - Is the name UTS46 normalised?
*
* User applications MUST check these two elements for each domain before
* offering them to users for registration.
*
* Applications should additionally check that the domains they are offering to
* register are controlled by this registrar, since calls to `register` will
* fail if this is not the case.
*/ | NatSpecMultiLine | configureDomainFor | function configureDomainFor(string memory name, uint price, uint referralFeePPM, address payable _owner, address _transfer) public owner_only(keccak256(bytes(name))) {
bytes32 label = keccak256(bytes(name));
Domain storage domain = domains[label];
if (BaseRegistrar(registrar).ownerOf(uint256(label)) != address(this)) {
BaseRegistrar(registrar).transferFrom(msg.sender, address(this), uint256(label));
BaseRegistrar(registrar).reclaim(uint256(label), address(this));
}
if (domain.owner != _owner) {
domain.owner = _owner;
}
if (keccak256(bytes(domain.name)) != label) {
// New listing
domain.name = name;
}
domain.price = price;
domain.referralFeePPM = referralFeePPM;
emit DomainConfigured(label);
}
| /**
* @dev Configures a domain, optionally transferring it to a new owner.
* @param name The name to configure.
* @param price The price in wei to charge for subdomain registrations.
* @param referralFeePPM The referral fee to offer, in parts per million.
* @param _owner The address to assign ownership of this domain to.
* @param _transfer The address to set as the transfer address for the name
* when the permanent registrar is replaced. Can only be set to a non-zero
* value once.
*/ | NatSpecMultiLine | v0.5.16+commit.9c3226ce | None | bzzr://8751e27803ad5386d933139faf690ecb1e80c3045ffede7816138b0531f8d76b | {
"func_code_index": [
2117,
3002
]
} | 2,529 |
ENSMigrationSubdomainRegistrar | @ensdomains/subdomain-registrar/contracts/EthRegistrarSubdomainRegistrar.sol | 0xe65d8aaf34cb91087d1598e0a15b582f57f217d9 | Solidity | EthRegistrarSubdomainRegistrar | contract EthRegistrarSubdomainRegistrar is AbstractSubdomainRegistrar {
struct Domain {
string name;
address payable owner;
uint price;
uint referralFeePPM;
}
mapping (bytes32 => Domain) domains;
constructor(ENS ens) AbstractSubdomainRegistrar(ens) public { }
/**
* @dev owner returns the address of the account that controls a domain.
* Initially this is a null address. If the name has been
* transferred to this contract, then the internal mapping is consulted
* to determine who controls it. If the owner is not set,
* the owner of the domain in the Registrar is returned.
* @param label The label hash of the deed to check.
* @return The address owning the deed.
*/
function owner(bytes32 label) public view returns (address) {
if (domains[label].owner != address(0x0)) {
return domains[label].owner;
}
return BaseRegistrar(registrar).ownerOf(uint256(label));
}
/**
* @dev Transfers internal control of a name to a new account. Does not update
* ENS.
* @param name The name to transfer.
* @param newOwner The address of the new owner.
*/
function transfer(string memory name, address payable newOwner) public owner_only(keccak256(bytes(name))) {
bytes32 label = keccak256(bytes(name));
emit OwnerChanged(label, domains[label].owner, newOwner);
domains[label].owner = newOwner;
}
/**
* @dev Configures a domain, optionally transferring it to a new owner.
* @param name The name to configure.
* @param price The price in wei to charge for subdomain registrations.
* @param referralFeePPM The referral fee to offer, in parts per million.
* @param _owner The address to assign ownership of this domain to.
* @param _transfer The address to set as the transfer address for the name
* when the permanent registrar is replaced. Can only be set to a non-zero
* value once.
*/
function configureDomainFor(string memory name, uint price, uint referralFeePPM, address payable _owner, address _transfer) public owner_only(keccak256(bytes(name))) {
bytes32 label = keccak256(bytes(name));
Domain storage domain = domains[label];
if (BaseRegistrar(registrar).ownerOf(uint256(label)) != address(this)) {
BaseRegistrar(registrar).transferFrom(msg.sender, address(this), uint256(label));
BaseRegistrar(registrar).reclaim(uint256(label), address(this));
}
if (domain.owner != _owner) {
domain.owner = _owner;
}
if (keccak256(bytes(domain.name)) != label) {
// New listing
domain.name = name;
}
domain.price = price;
domain.referralFeePPM = referralFeePPM;
emit DomainConfigured(label);
}
/**
* @dev Unlists a domain
* May only be called by the owner.
* @param name The name of the domain to unlist.
*/
function unlistDomain(string memory name) public owner_only(keccak256(bytes(name))) {
bytes32 label = keccak256(bytes(name));
Domain storage domain = domains[label];
emit DomainUnlisted(label);
domain.name = '';
domain.price = 0;
domain.referralFeePPM = 0;
}
/**
* @dev Returns information about a subdomain.
* @param label The label hash for the domain.
* @param subdomain The label for the subdomain.
* @return domain The name of the domain, or an empty string if the subdomain
* is unavailable.
* @return price The price to register a subdomain, in wei.
* @return rent The rent to retain a subdomain, in wei per second.
* @return referralFeePPM The referral fee for the dapp, in ppm.
*/
function query(bytes32 label, string calldata subdomain) external view returns (string memory domain, uint price, uint rent, uint referralFeePPM) {
bytes32 node = keccak256(abi.encodePacked(TLD_NODE, label));
bytes32 subnode = keccak256(abi.encodePacked(node, keccak256(bytes(subdomain))));
if (ens.owner(subnode) != address(0x0)) {
return ('', 0, 0, 0);
}
Domain storage data = domains[label];
return (data.name, data.price, 0, data.referralFeePPM);
}
/**
* @dev Registers a subdomain.
* @param label The label hash of the domain to register a subdomain of.
* @param subdomain The desired subdomain label.
* @param _subdomainOwner The account that should own the newly configured subdomain.
* @param referrer The address of the account to receive the referral fee.
*/
function register(bytes32 label, string calldata subdomain, address _subdomainOwner, address payable referrer, address resolver) external not_stopped payable {
address subdomainOwner = _subdomainOwner;
bytes32 domainNode = keccak256(abi.encodePacked(TLD_NODE, label));
bytes32 subdomainLabel = keccak256(bytes(subdomain));
// Subdomain must not be registered already.
require(ens.owner(keccak256(abi.encodePacked(domainNode, subdomainLabel))) == address(0));
Domain storage domain = domains[label];
// Domain must be available for registration
require(keccak256(bytes(domain.name)) == label);
// User must have paid enough
require(msg.value >= domain.price);
// Send any extra back
if (msg.value > domain.price) {
msg.sender.transfer(msg.value - domain.price);
}
// Send any referral fee
uint256 total = domain.price;
if (domain.referralFeePPM > 0 && referrer != address(0x0) && referrer != domain.owner) {
uint256 referralFee = (domain.price * domain.referralFeePPM) / 1000000;
referrer.transfer(referralFee);
total -= referralFee;
}
// Send the registration fee
if (total > 0) {
domain.owner.transfer(total);
}
// Register the domain
if (subdomainOwner == address(0x0)) {
subdomainOwner = msg.sender;
}
doRegistration(domainNode, subdomainLabel, subdomainOwner, Resolver(resolver));
emit NewRegistration(label, subdomain, subdomainOwner, referrer, domain.price);
}
function rentDue(bytes32 label, string calldata subdomain) external view returns (uint timestamp) {
return 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF;
}
/**
* @dev Migrates the domain to a new registrar.
* @param name The name of the domain to migrate.
*/
function migrate(string memory name) public owner_only(keccak256(bytes(name))) {
require(stopped);
require(migration != address(0x0));
bytes32 label = keccak256(bytes(name));
Domain storage domain = domains[label];
BaseRegistrar(registrar).approve(migration, uint256(label));
EthRegistrarSubdomainRegistrar(migration).configureDomainFor(
domain.name,
domain.price,
domain.referralFeePPM,
domain.owner,
address(0x0)
);
delete domains[label];
emit DomainTransferred(label, name);
}
function payRent(bytes32 label, string calldata subdomain) external payable {
revert();
}
} | /**
* @dev Implements an ENS registrar that sells subdomains on behalf of their owners.
*
* Users may register a subdomain by calling `register` with the name of the domain
* they wish to register under, and the label hash of the subdomain they want to
* register. They must also specify the new owner of the domain, and the referrer,
* who is paid an optional finder's fee. The registrar then configures a simple
* default resolver, which resolves `addr` lookups to the new owner, and sets
* the `owner` account as the owner of the subdomain in ENS.
*
* New domains may be added by calling `configureDomain`, then transferring
* ownership in the ENS registry to this contract. Ownership in the contract
* may be transferred using `transfer`, and a domain may be unlisted for sale
* using `unlistDomain`. There is (deliberately) no way to recover ownership
* in ENS once the name is transferred to this registrar.
*
* Critically, this contract does not check one key property of a listed domain:
*
* - Is the name UTS46 normalised?
*
* User applications MUST check these two elements for each domain before
* offering them to users for registration.
*
* Applications should additionally check that the domains they are offering to
* register are controlled by this registrar, since calls to `register` will
* fail if this is not the case.
*/ | NatSpecMultiLine | unlistDomain | function unlistDomain(string memory name) public owner_only(keccak256(bytes(name))) {
bytes32 label = keccak256(bytes(name));
Domain storage domain = domains[label];
emit DomainUnlisted(label);
domain.name = '';
domain.price = 0;
domain.referralFeePPM = 0;
}
| /**
* @dev Unlists a domain
* May only be called by the owner.
* @param name The name of the domain to unlist.
*/ | NatSpecMultiLine | v0.5.16+commit.9c3226ce | None | bzzr://8751e27803ad5386d933139faf690ecb1e80c3045ffede7816138b0531f8d76b | {
"func_code_index": [
3148,
3472
]
} | 2,530 |
ENSMigrationSubdomainRegistrar | @ensdomains/subdomain-registrar/contracts/EthRegistrarSubdomainRegistrar.sol | 0xe65d8aaf34cb91087d1598e0a15b582f57f217d9 | Solidity | EthRegistrarSubdomainRegistrar | contract EthRegistrarSubdomainRegistrar is AbstractSubdomainRegistrar {
struct Domain {
string name;
address payable owner;
uint price;
uint referralFeePPM;
}
mapping (bytes32 => Domain) domains;
constructor(ENS ens) AbstractSubdomainRegistrar(ens) public { }
/**
* @dev owner returns the address of the account that controls a domain.
* Initially this is a null address. If the name has been
* transferred to this contract, then the internal mapping is consulted
* to determine who controls it. If the owner is not set,
* the owner of the domain in the Registrar is returned.
* @param label The label hash of the deed to check.
* @return The address owning the deed.
*/
function owner(bytes32 label) public view returns (address) {
if (domains[label].owner != address(0x0)) {
return domains[label].owner;
}
return BaseRegistrar(registrar).ownerOf(uint256(label));
}
/**
* @dev Transfers internal control of a name to a new account. Does not update
* ENS.
* @param name The name to transfer.
* @param newOwner The address of the new owner.
*/
function transfer(string memory name, address payable newOwner) public owner_only(keccak256(bytes(name))) {
bytes32 label = keccak256(bytes(name));
emit OwnerChanged(label, domains[label].owner, newOwner);
domains[label].owner = newOwner;
}
/**
* @dev Configures a domain, optionally transferring it to a new owner.
* @param name The name to configure.
* @param price The price in wei to charge for subdomain registrations.
* @param referralFeePPM The referral fee to offer, in parts per million.
* @param _owner The address to assign ownership of this domain to.
* @param _transfer The address to set as the transfer address for the name
* when the permanent registrar is replaced. Can only be set to a non-zero
* value once.
*/
function configureDomainFor(string memory name, uint price, uint referralFeePPM, address payable _owner, address _transfer) public owner_only(keccak256(bytes(name))) {
bytes32 label = keccak256(bytes(name));
Domain storage domain = domains[label];
if (BaseRegistrar(registrar).ownerOf(uint256(label)) != address(this)) {
BaseRegistrar(registrar).transferFrom(msg.sender, address(this), uint256(label));
BaseRegistrar(registrar).reclaim(uint256(label), address(this));
}
if (domain.owner != _owner) {
domain.owner = _owner;
}
if (keccak256(bytes(domain.name)) != label) {
// New listing
domain.name = name;
}
domain.price = price;
domain.referralFeePPM = referralFeePPM;
emit DomainConfigured(label);
}
/**
* @dev Unlists a domain
* May only be called by the owner.
* @param name The name of the domain to unlist.
*/
function unlistDomain(string memory name) public owner_only(keccak256(bytes(name))) {
bytes32 label = keccak256(bytes(name));
Domain storage domain = domains[label];
emit DomainUnlisted(label);
domain.name = '';
domain.price = 0;
domain.referralFeePPM = 0;
}
/**
* @dev Returns information about a subdomain.
* @param label The label hash for the domain.
* @param subdomain The label for the subdomain.
* @return domain The name of the domain, or an empty string if the subdomain
* is unavailable.
* @return price The price to register a subdomain, in wei.
* @return rent The rent to retain a subdomain, in wei per second.
* @return referralFeePPM The referral fee for the dapp, in ppm.
*/
function query(bytes32 label, string calldata subdomain) external view returns (string memory domain, uint price, uint rent, uint referralFeePPM) {
bytes32 node = keccak256(abi.encodePacked(TLD_NODE, label));
bytes32 subnode = keccak256(abi.encodePacked(node, keccak256(bytes(subdomain))));
if (ens.owner(subnode) != address(0x0)) {
return ('', 0, 0, 0);
}
Domain storage data = domains[label];
return (data.name, data.price, 0, data.referralFeePPM);
}
/**
* @dev Registers a subdomain.
* @param label The label hash of the domain to register a subdomain of.
* @param subdomain The desired subdomain label.
* @param _subdomainOwner The account that should own the newly configured subdomain.
* @param referrer The address of the account to receive the referral fee.
*/
function register(bytes32 label, string calldata subdomain, address _subdomainOwner, address payable referrer, address resolver) external not_stopped payable {
address subdomainOwner = _subdomainOwner;
bytes32 domainNode = keccak256(abi.encodePacked(TLD_NODE, label));
bytes32 subdomainLabel = keccak256(bytes(subdomain));
// Subdomain must not be registered already.
require(ens.owner(keccak256(abi.encodePacked(domainNode, subdomainLabel))) == address(0));
Domain storage domain = domains[label];
// Domain must be available for registration
require(keccak256(bytes(domain.name)) == label);
// User must have paid enough
require(msg.value >= domain.price);
// Send any extra back
if (msg.value > domain.price) {
msg.sender.transfer(msg.value - domain.price);
}
// Send any referral fee
uint256 total = domain.price;
if (domain.referralFeePPM > 0 && referrer != address(0x0) && referrer != domain.owner) {
uint256 referralFee = (domain.price * domain.referralFeePPM) / 1000000;
referrer.transfer(referralFee);
total -= referralFee;
}
// Send the registration fee
if (total > 0) {
domain.owner.transfer(total);
}
// Register the domain
if (subdomainOwner == address(0x0)) {
subdomainOwner = msg.sender;
}
doRegistration(domainNode, subdomainLabel, subdomainOwner, Resolver(resolver));
emit NewRegistration(label, subdomain, subdomainOwner, referrer, domain.price);
}
function rentDue(bytes32 label, string calldata subdomain) external view returns (uint timestamp) {
return 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF;
}
/**
* @dev Migrates the domain to a new registrar.
* @param name The name of the domain to migrate.
*/
function migrate(string memory name) public owner_only(keccak256(bytes(name))) {
require(stopped);
require(migration != address(0x0));
bytes32 label = keccak256(bytes(name));
Domain storage domain = domains[label];
BaseRegistrar(registrar).approve(migration, uint256(label));
EthRegistrarSubdomainRegistrar(migration).configureDomainFor(
domain.name,
domain.price,
domain.referralFeePPM,
domain.owner,
address(0x0)
);
delete domains[label];
emit DomainTransferred(label, name);
}
function payRent(bytes32 label, string calldata subdomain) external payable {
revert();
}
} | /**
* @dev Implements an ENS registrar that sells subdomains on behalf of their owners.
*
* Users may register a subdomain by calling `register` with the name of the domain
* they wish to register under, and the label hash of the subdomain they want to
* register. They must also specify the new owner of the domain, and the referrer,
* who is paid an optional finder's fee. The registrar then configures a simple
* default resolver, which resolves `addr` lookups to the new owner, and sets
* the `owner` account as the owner of the subdomain in ENS.
*
* New domains may be added by calling `configureDomain`, then transferring
* ownership in the ENS registry to this contract. Ownership in the contract
* may be transferred using `transfer`, and a domain may be unlisted for sale
* using `unlistDomain`. There is (deliberately) no way to recover ownership
* in ENS once the name is transferred to this registrar.
*
* Critically, this contract does not check one key property of a listed domain:
*
* - Is the name UTS46 normalised?
*
* User applications MUST check these two elements for each domain before
* offering them to users for registration.
*
* Applications should additionally check that the domains they are offering to
* register are controlled by this registrar, since calls to `register` will
* fail if this is not the case.
*/ | NatSpecMultiLine | query | function query(bytes32 label, string calldata subdomain) external view returns (string memory domain, uint price, uint rent, uint referralFeePPM) {
bytes32 node = keccak256(abi.encodePacked(TLD_NODE, label));
bytes32 subnode = keccak256(abi.encodePacked(node, keccak256(bytes(subdomain))));
if (ens.owner(subnode) != address(0x0)) {
return ('', 0, 0, 0);
}
Domain storage data = domains[label];
return (data.name, data.price, 0, data.referralFeePPM);
}
| /**
* @dev Returns information about a subdomain.
* @param label The label hash for the domain.
* @param subdomain The label for the subdomain.
* @return domain The name of the domain, or an empty string if the subdomain
* is unavailable.
* @return price The price to register a subdomain, in wei.
* @return rent The rent to retain a subdomain, in wei per second.
* @return referralFeePPM The referral fee for the dapp, in ppm.
*/ | NatSpecMultiLine | v0.5.16+commit.9c3226ce | None | bzzr://8751e27803ad5386d933139faf690ecb1e80c3045ffede7816138b0531f8d76b | {
"func_code_index": [
3980,
4513
]
} | 2,531 |
ENSMigrationSubdomainRegistrar | @ensdomains/subdomain-registrar/contracts/EthRegistrarSubdomainRegistrar.sol | 0xe65d8aaf34cb91087d1598e0a15b582f57f217d9 | Solidity | EthRegistrarSubdomainRegistrar | contract EthRegistrarSubdomainRegistrar is AbstractSubdomainRegistrar {
struct Domain {
string name;
address payable owner;
uint price;
uint referralFeePPM;
}
mapping (bytes32 => Domain) domains;
constructor(ENS ens) AbstractSubdomainRegistrar(ens) public { }
/**
* @dev owner returns the address of the account that controls a domain.
* Initially this is a null address. If the name has been
* transferred to this contract, then the internal mapping is consulted
* to determine who controls it. If the owner is not set,
* the owner of the domain in the Registrar is returned.
* @param label The label hash of the deed to check.
* @return The address owning the deed.
*/
function owner(bytes32 label) public view returns (address) {
if (domains[label].owner != address(0x0)) {
return domains[label].owner;
}
return BaseRegistrar(registrar).ownerOf(uint256(label));
}
/**
* @dev Transfers internal control of a name to a new account. Does not update
* ENS.
* @param name The name to transfer.
* @param newOwner The address of the new owner.
*/
function transfer(string memory name, address payable newOwner) public owner_only(keccak256(bytes(name))) {
bytes32 label = keccak256(bytes(name));
emit OwnerChanged(label, domains[label].owner, newOwner);
domains[label].owner = newOwner;
}
/**
* @dev Configures a domain, optionally transferring it to a new owner.
* @param name The name to configure.
* @param price The price in wei to charge for subdomain registrations.
* @param referralFeePPM The referral fee to offer, in parts per million.
* @param _owner The address to assign ownership of this domain to.
* @param _transfer The address to set as the transfer address for the name
* when the permanent registrar is replaced. Can only be set to a non-zero
* value once.
*/
function configureDomainFor(string memory name, uint price, uint referralFeePPM, address payable _owner, address _transfer) public owner_only(keccak256(bytes(name))) {
bytes32 label = keccak256(bytes(name));
Domain storage domain = domains[label];
if (BaseRegistrar(registrar).ownerOf(uint256(label)) != address(this)) {
BaseRegistrar(registrar).transferFrom(msg.sender, address(this), uint256(label));
BaseRegistrar(registrar).reclaim(uint256(label), address(this));
}
if (domain.owner != _owner) {
domain.owner = _owner;
}
if (keccak256(bytes(domain.name)) != label) {
// New listing
domain.name = name;
}
domain.price = price;
domain.referralFeePPM = referralFeePPM;
emit DomainConfigured(label);
}
/**
* @dev Unlists a domain
* May only be called by the owner.
* @param name The name of the domain to unlist.
*/
function unlistDomain(string memory name) public owner_only(keccak256(bytes(name))) {
bytes32 label = keccak256(bytes(name));
Domain storage domain = domains[label];
emit DomainUnlisted(label);
domain.name = '';
domain.price = 0;
domain.referralFeePPM = 0;
}
/**
* @dev Returns information about a subdomain.
* @param label The label hash for the domain.
* @param subdomain The label for the subdomain.
* @return domain The name of the domain, or an empty string if the subdomain
* is unavailable.
* @return price The price to register a subdomain, in wei.
* @return rent The rent to retain a subdomain, in wei per second.
* @return referralFeePPM The referral fee for the dapp, in ppm.
*/
function query(bytes32 label, string calldata subdomain) external view returns (string memory domain, uint price, uint rent, uint referralFeePPM) {
bytes32 node = keccak256(abi.encodePacked(TLD_NODE, label));
bytes32 subnode = keccak256(abi.encodePacked(node, keccak256(bytes(subdomain))));
if (ens.owner(subnode) != address(0x0)) {
return ('', 0, 0, 0);
}
Domain storage data = domains[label];
return (data.name, data.price, 0, data.referralFeePPM);
}
/**
* @dev Registers a subdomain.
* @param label The label hash of the domain to register a subdomain of.
* @param subdomain The desired subdomain label.
* @param _subdomainOwner The account that should own the newly configured subdomain.
* @param referrer The address of the account to receive the referral fee.
*/
function register(bytes32 label, string calldata subdomain, address _subdomainOwner, address payable referrer, address resolver) external not_stopped payable {
address subdomainOwner = _subdomainOwner;
bytes32 domainNode = keccak256(abi.encodePacked(TLD_NODE, label));
bytes32 subdomainLabel = keccak256(bytes(subdomain));
// Subdomain must not be registered already.
require(ens.owner(keccak256(abi.encodePacked(domainNode, subdomainLabel))) == address(0));
Domain storage domain = domains[label];
// Domain must be available for registration
require(keccak256(bytes(domain.name)) == label);
// User must have paid enough
require(msg.value >= domain.price);
// Send any extra back
if (msg.value > domain.price) {
msg.sender.transfer(msg.value - domain.price);
}
// Send any referral fee
uint256 total = domain.price;
if (domain.referralFeePPM > 0 && referrer != address(0x0) && referrer != domain.owner) {
uint256 referralFee = (domain.price * domain.referralFeePPM) / 1000000;
referrer.transfer(referralFee);
total -= referralFee;
}
// Send the registration fee
if (total > 0) {
domain.owner.transfer(total);
}
// Register the domain
if (subdomainOwner == address(0x0)) {
subdomainOwner = msg.sender;
}
doRegistration(domainNode, subdomainLabel, subdomainOwner, Resolver(resolver));
emit NewRegistration(label, subdomain, subdomainOwner, referrer, domain.price);
}
function rentDue(bytes32 label, string calldata subdomain) external view returns (uint timestamp) {
return 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF;
}
/**
* @dev Migrates the domain to a new registrar.
* @param name The name of the domain to migrate.
*/
function migrate(string memory name) public owner_only(keccak256(bytes(name))) {
require(stopped);
require(migration != address(0x0));
bytes32 label = keccak256(bytes(name));
Domain storage domain = domains[label];
BaseRegistrar(registrar).approve(migration, uint256(label));
EthRegistrarSubdomainRegistrar(migration).configureDomainFor(
domain.name,
domain.price,
domain.referralFeePPM,
domain.owner,
address(0x0)
);
delete domains[label];
emit DomainTransferred(label, name);
}
function payRent(bytes32 label, string calldata subdomain) external payable {
revert();
}
} | /**
* @dev Implements an ENS registrar that sells subdomains on behalf of their owners.
*
* Users may register a subdomain by calling `register` with the name of the domain
* they wish to register under, and the label hash of the subdomain they want to
* register. They must also specify the new owner of the domain, and the referrer,
* who is paid an optional finder's fee. The registrar then configures a simple
* default resolver, which resolves `addr` lookups to the new owner, and sets
* the `owner` account as the owner of the subdomain in ENS.
*
* New domains may be added by calling `configureDomain`, then transferring
* ownership in the ENS registry to this contract. Ownership in the contract
* may be transferred using `transfer`, and a domain may be unlisted for sale
* using `unlistDomain`. There is (deliberately) no way to recover ownership
* in ENS once the name is transferred to this registrar.
*
* Critically, this contract does not check one key property of a listed domain:
*
* - Is the name UTS46 normalised?
*
* User applications MUST check these two elements for each domain before
* offering them to users for registration.
*
* Applications should additionally check that the domains they are offering to
* register are controlled by this registrar, since calls to `register` will
* fail if this is not the case.
*/ | NatSpecMultiLine | register | function register(bytes32 label, string calldata subdomain, address _subdomainOwner, address payable referrer, address resolver) external not_stopped payable {
address subdomainOwner = _subdomainOwner;
bytes32 domainNode = keccak256(abi.encodePacked(TLD_NODE, label));
bytes32 subdomainLabel = keccak256(bytes(subdomain));
// Subdomain must not be registered already.
require(ens.owner(keccak256(abi.encodePacked(domainNode, subdomainLabel))) == address(0));
Domain storage domain = domains[label];
// Domain must be available for registration
require(keccak256(bytes(domain.name)) == label);
// User must have paid enough
require(msg.value >= domain.price);
// Send any extra back
if (msg.value > domain.price) {
msg.sender.transfer(msg.value - domain.price);
}
// Send any referral fee
uint256 total = domain.price;
if (domain.referralFeePPM > 0 && referrer != address(0x0) && referrer != domain.owner) {
uint256 referralFee = (domain.price * domain.referralFeePPM) / 1000000;
referrer.transfer(referralFee);
total -= referralFee;
}
// Send the registration fee
if (total > 0) {
domain.owner.transfer(total);
}
// Register the domain
if (subdomainOwner == address(0x0)) {
subdomainOwner = msg.sender;
}
doRegistration(domainNode, subdomainLabel, subdomainOwner, Resolver(resolver));
emit NewRegistration(label, subdomain, subdomainOwner, referrer, domain.price);
}
| /**
* @dev Registers a subdomain.
* @param label The label hash of the domain to register a subdomain of.
* @param subdomain The desired subdomain label.
* @param _subdomainOwner The account that should own the newly configured subdomain.
* @param referrer The address of the account to receive the referral fee.
*/ | NatSpecMultiLine | v0.5.16+commit.9c3226ce | None | bzzr://8751e27803ad5386d933139faf690ecb1e80c3045ffede7816138b0531f8d76b | {
"func_code_index": [
4873,
6570
]
} | 2,532 |
ENSMigrationSubdomainRegistrar | @ensdomains/subdomain-registrar/contracts/EthRegistrarSubdomainRegistrar.sol | 0xe65d8aaf34cb91087d1598e0a15b582f57f217d9 | Solidity | EthRegistrarSubdomainRegistrar | contract EthRegistrarSubdomainRegistrar is AbstractSubdomainRegistrar {
struct Domain {
string name;
address payable owner;
uint price;
uint referralFeePPM;
}
mapping (bytes32 => Domain) domains;
constructor(ENS ens) AbstractSubdomainRegistrar(ens) public { }
/**
* @dev owner returns the address of the account that controls a domain.
* Initially this is a null address. If the name has been
* transferred to this contract, then the internal mapping is consulted
* to determine who controls it. If the owner is not set,
* the owner of the domain in the Registrar is returned.
* @param label The label hash of the deed to check.
* @return The address owning the deed.
*/
function owner(bytes32 label) public view returns (address) {
if (domains[label].owner != address(0x0)) {
return domains[label].owner;
}
return BaseRegistrar(registrar).ownerOf(uint256(label));
}
/**
* @dev Transfers internal control of a name to a new account. Does not update
* ENS.
* @param name The name to transfer.
* @param newOwner The address of the new owner.
*/
function transfer(string memory name, address payable newOwner) public owner_only(keccak256(bytes(name))) {
bytes32 label = keccak256(bytes(name));
emit OwnerChanged(label, domains[label].owner, newOwner);
domains[label].owner = newOwner;
}
/**
* @dev Configures a domain, optionally transferring it to a new owner.
* @param name The name to configure.
* @param price The price in wei to charge for subdomain registrations.
* @param referralFeePPM The referral fee to offer, in parts per million.
* @param _owner The address to assign ownership of this domain to.
* @param _transfer The address to set as the transfer address for the name
* when the permanent registrar is replaced. Can only be set to a non-zero
* value once.
*/
function configureDomainFor(string memory name, uint price, uint referralFeePPM, address payable _owner, address _transfer) public owner_only(keccak256(bytes(name))) {
bytes32 label = keccak256(bytes(name));
Domain storage domain = domains[label];
if (BaseRegistrar(registrar).ownerOf(uint256(label)) != address(this)) {
BaseRegistrar(registrar).transferFrom(msg.sender, address(this), uint256(label));
BaseRegistrar(registrar).reclaim(uint256(label), address(this));
}
if (domain.owner != _owner) {
domain.owner = _owner;
}
if (keccak256(bytes(domain.name)) != label) {
// New listing
domain.name = name;
}
domain.price = price;
domain.referralFeePPM = referralFeePPM;
emit DomainConfigured(label);
}
/**
* @dev Unlists a domain
* May only be called by the owner.
* @param name The name of the domain to unlist.
*/
function unlistDomain(string memory name) public owner_only(keccak256(bytes(name))) {
bytes32 label = keccak256(bytes(name));
Domain storage domain = domains[label];
emit DomainUnlisted(label);
domain.name = '';
domain.price = 0;
domain.referralFeePPM = 0;
}
/**
* @dev Returns information about a subdomain.
* @param label The label hash for the domain.
* @param subdomain The label for the subdomain.
* @return domain The name of the domain, or an empty string if the subdomain
* is unavailable.
* @return price The price to register a subdomain, in wei.
* @return rent The rent to retain a subdomain, in wei per second.
* @return referralFeePPM The referral fee for the dapp, in ppm.
*/
function query(bytes32 label, string calldata subdomain) external view returns (string memory domain, uint price, uint rent, uint referralFeePPM) {
bytes32 node = keccak256(abi.encodePacked(TLD_NODE, label));
bytes32 subnode = keccak256(abi.encodePacked(node, keccak256(bytes(subdomain))));
if (ens.owner(subnode) != address(0x0)) {
return ('', 0, 0, 0);
}
Domain storage data = domains[label];
return (data.name, data.price, 0, data.referralFeePPM);
}
/**
* @dev Registers a subdomain.
* @param label The label hash of the domain to register a subdomain of.
* @param subdomain The desired subdomain label.
* @param _subdomainOwner The account that should own the newly configured subdomain.
* @param referrer The address of the account to receive the referral fee.
*/
function register(bytes32 label, string calldata subdomain, address _subdomainOwner, address payable referrer, address resolver) external not_stopped payable {
address subdomainOwner = _subdomainOwner;
bytes32 domainNode = keccak256(abi.encodePacked(TLD_NODE, label));
bytes32 subdomainLabel = keccak256(bytes(subdomain));
// Subdomain must not be registered already.
require(ens.owner(keccak256(abi.encodePacked(domainNode, subdomainLabel))) == address(0));
Domain storage domain = domains[label];
// Domain must be available for registration
require(keccak256(bytes(domain.name)) == label);
// User must have paid enough
require(msg.value >= domain.price);
// Send any extra back
if (msg.value > domain.price) {
msg.sender.transfer(msg.value - domain.price);
}
// Send any referral fee
uint256 total = domain.price;
if (domain.referralFeePPM > 0 && referrer != address(0x0) && referrer != domain.owner) {
uint256 referralFee = (domain.price * domain.referralFeePPM) / 1000000;
referrer.transfer(referralFee);
total -= referralFee;
}
// Send the registration fee
if (total > 0) {
domain.owner.transfer(total);
}
// Register the domain
if (subdomainOwner == address(0x0)) {
subdomainOwner = msg.sender;
}
doRegistration(domainNode, subdomainLabel, subdomainOwner, Resolver(resolver));
emit NewRegistration(label, subdomain, subdomainOwner, referrer, domain.price);
}
function rentDue(bytes32 label, string calldata subdomain) external view returns (uint timestamp) {
return 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF;
}
/**
* @dev Migrates the domain to a new registrar.
* @param name The name of the domain to migrate.
*/
function migrate(string memory name) public owner_only(keccak256(bytes(name))) {
require(stopped);
require(migration != address(0x0));
bytes32 label = keccak256(bytes(name));
Domain storage domain = domains[label];
BaseRegistrar(registrar).approve(migration, uint256(label));
EthRegistrarSubdomainRegistrar(migration).configureDomainFor(
domain.name,
domain.price,
domain.referralFeePPM,
domain.owner,
address(0x0)
);
delete domains[label];
emit DomainTransferred(label, name);
}
function payRent(bytes32 label, string calldata subdomain) external payable {
revert();
}
} | /**
* @dev Implements an ENS registrar that sells subdomains on behalf of their owners.
*
* Users may register a subdomain by calling `register` with the name of the domain
* they wish to register under, and the label hash of the subdomain they want to
* register. They must also specify the new owner of the domain, and the referrer,
* who is paid an optional finder's fee. The registrar then configures a simple
* default resolver, which resolves `addr` lookups to the new owner, and sets
* the `owner` account as the owner of the subdomain in ENS.
*
* New domains may be added by calling `configureDomain`, then transferring
* ownership in the ENS registry to this contract. Ownership in the contract
* may be transferred using `transfer`, and a domain may be unlisted for sale
* using `unlistDomain`. There is (deliberately) no way to recover ownership
* in ENS once the name is transferred to this registrar.
*
* Critically, this contract does not check one key property of a listed domain:
*
* - Is the name UTS46 normalised?
*
* User applications MUST check these two elements for each domain before
* offering them to users for registration.
*
* Applications should additionally check that the domains they are offering to
* register are controlled by this registrar, since calls to `register` will
* fail if this is not the case.
*/ | NatSpecMultiLine | migrate | function migrate(string memory name) public owner_only(keccak256(bytes(name))) {
require(stopped);
require(migration != address(0x0));
bytes32 label = keccak256(bytes(name));
Domain storage domain = domains[label];
BaseRegistrar(registrar).approve(migration, uint256(label));
EthRegistrarSubdomainRegistrar(migration).configureDomainFor(
domain.name,
domain.price,
domain.referralFeePPM,
domain.owner,
address(0x0)
);
delete domains[label];
emit DomainTransferred(label, name);
}
| /**
* @dev Migrates the domain to a new registrar.
* @param name The name of the domain to migrate.
*/ | NatSpecMultiLine | v0.5.16+commit.9c3226ce | None | bzzr://8751e27803ad5386d933139faf690ecb1e80c3045ffede7816138b0531f8d76b | {
"func_code_index": [
6897,
7542
]
} | 2,533 |
HippoBohemianToken | HippoBohemianToken.sol | 0x1eb553e50aaf4251dd3fc00def6e95b862285d41 | Solidity | Token | contract Token {
/// @return total amount of tokens
function totalSupply() constant returns (uint256 supply) {}
/// @param _owner The address from which the balance will be retrieved
/// @return The balance
function balanceOf(address _owner) constant returns (uint256 balance) {}
/// @notice send `_value` token to `_to` from `msg.sender`
/// @param _to The address of the recipient
/// @param _value The amount of token to be transferred
/// @return Whether the transfer was successful or not
function transfer(address _to, uint256 _value) returns (bool success) {}
/// @notice send `_value` token to `_to` from `_from` on the condition it is approved by `_from`
/// @param _from The address of the sender
/// @param _to The address of the recipient
/// @param _value The amount of token to be transferred
/// @return Whether the transfer was successful or not
function transferFrom(address _from, address _to, uint256 _value) returns (bool success) {}
/// @notice `msg.sender` approves `_addr` to spend `_value` tokens
/// @param _spender The address of the account able to transfer the tokens
/// @param _value The amount of wei to be approved for transfer
/// @return Whether the approval was successful or not
function approve(address _spender, uint256 _value) returns (bool success) {}
/// @param _owner The address of the account owning tokens
/// @param _spender The address of the account able to transfer the tokens
/// @return Amount of remaining tokens allowed to spent
function allowance(address _owner, address _spender) constant returns (uint256 remaining) {}
event Transfer(address indexed _from, address indexed _to, uint256 _value);
event Approval(address indexed _owner, address indexed _spender, uint256 _value);
} | totalSupply | function totalSupply() constant returns (uint256 supply) {}
| /// @return total amount of tokens | NatSpecSingleLine | v0.4.18+commit.9cf6e910 | bzzr://54d62638dd2483dca2133440895cd4111a23aa44082894b649553205c23f007e | {
"func_code_index": [
60,
124
]
} | 2,534 |
|||
HippoBohemianToken | HippoBohemianToken.sol | 0x1eb553e50aaf4251dd3fc00def6e95b862285d41 | Solidity | Token | contract Token {
/// @return total amount of tokens
function totalSupply() constant returns (uint256 supply) {}
/// @param _owner The address from which the balance will be retrieved
/// @return The balance
function balanceOf(address _owner) constant returns (uint256 balance) {}
/// @notice send `_value` token to `_to` from `msg.sender`
/// @param _to The address of the recipient
/// @param _value The amount of token to be transferred
/// @return Whether the transfer was successful or not
function transfer(address _to, uint256 _value) returns (bool success) {}
/// @notice send `_value` token to `_to` from `_from` on the condition it is approved by `_from`
/// @param _from The address of the sender
/// @param _to The address of the recipient
/// @param _value The amount of token to be transferred
/// @return Whether the transfer was successful or not
function transferFrom(address _from, address _to, uint256 _value) returns (bool success) {}
/// @notice `msg.sender` approves `_addr` to spend `_value` tokens
/// @param _spender The address of the account able to transfer the tokens
/// @param _value The amount of wei to be approved for transfer
/// @return Whether the approval was successful or not
function approve(address _spender, uint256 _value) returns (bool success) {}
/// @param _owner The address of the account owning tokens
/// @param _spender The address of the account able to transfer the tokens
/// @return Amount of remaining tokens allowed to spent
function allowance(address _owner, address _spender) constant returns (uint256 remaining) {}
event Transfer(address indexed _from, address indexed _to, uint256 _value);
event Approval(address indexed _owner, address indexed _spender, uint256 _value);
} | balanceOf | function balanceOf(address _owner) constant returns (uint256 balance) {}
| /// @param _owner The address from which the balance will be retrieved
/// @return The balance | NatSpecSingleLine | v0.4.18+commit.9cf6e910 | bzzr://54d62638dd2483dca2133440895cd4111a23aa44082894b649553205c23f007e | {
"func_code_index": [
232,
309
]
} | 2,535 |
|||
HippoBohemianToken | HippoBohemianToken.sol | 0x1eb553e50aaf4251dd3fc00def6e95b862285d41 | Solidity | Token | contract Token {
/// @return total amount of tokens
function totalSupply() constant returns (uint256 supply) {}
/// @param _owner The address from which the balance will be retrieved
/// @return The balance
function balanceOf(address _owner) constant returns (uint256 balance) {}
/// @notice send `_value` token to `_to` from `msg.sender`
/// @param _to The address of the recipient
/// @param _value The amount of token to be transferred
/// @return Whether the transfer was successful or not
function transfer(address _to, uint256 _value) returns (bool success) {}
/// @notice send `_value` token to `_to` from `_from` on the condition it is approved by `_from`
/// @param _from The address of the sender
/// @param _to The address of the recipient
/// @param _value The amount of token to be transferred
/// @return Whether the transfer was successful or not
function transferFrom(address _from, address _to, uint256 _value) returns (bool success) {}
/// @notice `msg.sender` approves `_addr` to spend `_value` tokens
/// @param _spender The address of the account able to transfer the tokens
/// @param _value The amount of wei to be approved for transfer
/// @return Whether the approval was successful or not
function approve(address _spender, uint256 _value) returns (bool success) {}
/// @param _owner The address of the account owning tokens
/// @param _spender The address of the account able to transfer the tokens
/// @return Amount of remaining tokens allowed to spent
function allowance(address _owner, address _spender) constant returns (uint256 remaining) {}
event Transfer(address indexed _from, address indexed _to, uint256 _value);
event Approval(address indexed _owner, address indexed _spender, uint256 _value);
} | transfer | function transfer(address _to, uint256 _value) returns (bool success) {}
| /// @notice send `_value` token to `_to` from `msg.sender`
/// @param _to The address of the recipient
/// @param _value The amount of token to be transferred
/// @return Whether the transfer was successful or not | NatSpecSingleLine | v0.4.18+commit.9cf6e910 | bzzr://54d62638dd2483dca2133440895cd4111a23aa44082894b649553205c23f007e | {
"func_code_index": [
546,
623
]
} | 2,536 |
|||
HippoBohemianToken | HippoBohemianToken.sol | 0x1eb553e50aaf4251dd3fc00def6e95b862285d41 | Solidity | Token | contract Token {
/// @return total amount of tokens
function totalSupply() constant returns (uint256 supply) {}
/// @param _owner The address from which the balance will be retrieved
/// @return The balance
function balanceOf(address _owner) constant returns (uint256 balance) {}
/// @notice send `_value` token to `_to` from `msg.sender`
/// @param _to The address of the recipient
/// @param _value The amount of token to be transferred
/// @return Whether the transfer was successful or not
function transfer(address _to, uint256 _value) returns (bool success) {}
/// @notice send `_value` token to `_to` from `_from` on the condition it is approved by `_from`
/// @param _from The address of the sender
/// @param _to The address of the recipient
/// @param _value The amount of token to be transferred
/// @return Whether the transfer was successful or not
function transferFrom(address _from, address _to, uint256 _value) returns (bool success) {}
/// @notice `msg.sender` approves `_addr` to spend `_value` tokens
/// @param _spender The address of the account able to transfer the tokens
/// @param _value The amount of wei to be approved for transfer
/// @return Whether the approval was successful or not
function approve(address _spender, uint256 _value) returns (bool success) {}
/// @param _owner The address of the account owning tokens
/// @param _spender The address of the account able to transfer the tokens
/// @return Amount of remaining tokens allowed to spent
function allowance(address _owner, address _spender) constant returns (uint256 remaining) {}
event Transfer(address indexed _from, address indexed _to, uint256 _value);
event Approval(address indexed _owner, address indexed _spender, uint256 _value);
} | transferFrom | function transferFrom(address _from, address _to, uint256 _value) returns (bool success) {}
| /// @notice send `_value` token to `_to` from `_from` on the condition it is approved by `_from`
/// @param _from The address of the sender
/// @param _to The address of the recipient
/// @param _value The amount of token to be transferred
/// @return Whether the transfer was successful or not | NatSpecSingleLine | v0.4.18+commit.9cf6e910 | bzzr://54d62638dd2483dca2133440895cd4111a23aa44082894b649553205c23f007e | {
"func_code_index": [
946,
1042
]
} | 2,537 |
|||
HippoBohemianToken | HippoBohemianToken.sol | 0x1eb553e50aaf4251dd3fc00def6e95b862285d41 | Solidity | Token | contract Token {
/// @return total amount of tokens
function totalSupply() constant returns (uint256 supply) {}
/// @param _owner The address from which the balance will be retrieved
/// @return The balance
function balanceOf(address _owner) constant returns (uint256 balance) {}
/// @notice send `_value` token to `_to` from `msg.sender`
/// @param _to The address of the recipient
/// @param _value The amount of token to be transferred
/// @return Whether the transfer was successful or not
function transfer(address _to, uint256 _value) returns (bool success) {}
/// @notice send `_value` token to `_to` from `_from` on the condition it is approved by `_from`
/// @param _from The address of the sender
/// @param _to The address of the recipient
/// @param _value The amount of token to be transferred
/// @return Whether the transfer was successful or not
function transferFrom(address _from, address _to, uint256 _value) returns (bool success) {}
/// @notice `msg.sender` approves `_addr` to spend `_value` tokens
/// @param _spender The address of the account able to transfer the tokens
/// @param _value The amount of wei to be approved for transfer
/// @return Whether the approval was successful or not
function approve(address _spender, uint256 _value) returns (bool success) {}
/// @param _owner The address of the account owning tokens
/// @param _spender The address of the account able to transfer the tokens
/// @return Amount of remaining tokens allowed to spent
function allowance(address _owner, address _spender) constant returns (uint256 remaining) {}
event Transfer(address indexed _from, address indexed _to, uint256 _value);
event Approval(address indexed _owner, address indexed _spender, uint256 _value);
} | approve | function approve(address _spender, uint256 _value) returns (bool success) {}
| /// @notice `msg.sender` approves `_addr` to spend `_value` tokens
/// @param _spender The address of the account able to transfer the tokens
/// @param _value The amount of wei to be approved for transfer
/// @return Whether the approval was successful or not | NatSpecSingleLine | v0.4.18+commit.9cf6e910 | bzzr://54d62638dd2483dca2133440895cd4111a23aa44082894b649553205c23f007e | {
"func_code_index": [
1326,
1407
]
} | 2,538 |
|||
HippoBohemianToken | HippoBohemianToken.sol | 0x1eb553e50aaf4251dd3fc00def6e95b862285d41 | Solidity | Token | contract Token {
/// @return total amount of tokens
function totalSupply() constant returns (uint256 supply) {}
/// @param _owner The address from which the balance will be retrieved
/// @return The balance
function balanceOf(address _owner) constant returns (uint256 balance) {}
/// @notice send `_value` token to `_to` from `msg.sender`
/// @param _to The address of the recipient
/// @param _value The amount of token to be transferred
/// @return Whether the transfer was successful or not
function transfer(address _to, uint256 _value) returns (bool success) {}
/// @notice send `_value` token to `_to` from `_from` on the condition it is approved by `_from`
/// @param _from The address of the sender
/// @param _to The address of the recipient
/// @param _value The amount of token to be transferred
/// @return Whether the transfer was successful or not
function transferFrom(address _from, address _to, uint256 _value) returns (bool success) {}
/// @notice `msg.sender` approves `_addr` to spend `_value` tokens
/// @param _spender The address of the account able to transfer the tokens
/// @param _value The amount of wei to be approved for transfer
/// @return Whether the approval was successful or not
function approve(address _spender, uint256 _value) returns (bool success) {}
/// @param _owner The address of the account owning tokens
/// @param _spender The address of the account able to transfer the tokens
/// @return Amount of remaining tokens allowed to spent
function allowance(address _owner, address _spender) constant returns (uint256 remaining) {}
event Transfer(address indexed _from, address indexed _to, uint256 _value);
event Approval(address indexed _owner, address indexed _spender, uint256 _value);
} | allowance | function allowance(address _owner, address _spender) constant returns (uint256 remaining) {}
| /// @param _owner The address of the account owning tokens
/// @param _spender The address of the account able to transfer the tokens
/// @return Amount of remaining tokens allowed to spent | NatSpecSingleLine | v0.4.18+commit.9cf6e910 | bzzr://54d62638dd2483dca2133440895cd4111a23aa44082894b649553205c23f007e | {
"func_code_index": [
1615,
1712
]
} | 2,539 |
|||
HippoBohemianToken | HippoBohemianToken.sol | 0x1eb553e50aaf4251dd3fc00def6e95b862285d41 | Solidity | HippoBohemianToken | contract HippoBohemianToken is StandardToken {
function () {
//if ether is sent to this address, send it back.
throw;
}
/* Public variables of the token */
/*
NOTE:
The following variables are OPTIONAL vanities. One does not have to include them.
They allow one to customise the token contract & in no way influences the core functionality.
Some wallets/interfaces might not even bother to look at this information.
*/
string public name; //fancy name: eg Simon Bucks
uint8 public decimals; //How many decimals to show. ie. There could 1000 base units with 3 decimals. Meaning 0.980 SBX = 980 base units. It's like comparing 1 wei to 1 ether.
string public symbol; //An identifier: eg SBX
string public version = 'H1.0'; //human 0.1 standard. Just an arbitrary versioning scheme.
//
// CHANGE THESE VALUES FOR YOUR TOKEN
//
//make sure this function name matches the contract name above. So if you're token is called TutorialToken, make sure the //contract name above is also TutorialToken instead of ERC20Token
function HippoBohemianToken(
) {
balances[msg.sender] = 100000; // Give the creator all initial tokens (100000 for example)
totalSupply = 100000; // Update total supply (100000 for example)
name = "HippoBohemian"; // Set the name for display purposes
decimals = 0; // Amount of decimals for display purposes
symbol = "HPB"; // Set the symbol for display purposes
}
/* Approves and then calls the receiving contract */
function approveAndCall(address _spender, uint256 _value, bytes _extraData) returns (bool success) {
allowed[msg.sender][_spender] = _value;
Approval(msg.sender, _spender, _value);
//call the receiveApproval function on the contract you want to be notified. This crafts the function signature manually so one doesn't have to include a contract in here just for this.
//receiveApproval(address _from, uint256 _value, address _tokenContract, bytes _extraData)
//it is assumed that when does this that the call *should* succeed, otherwise one would use vanilla approve instead.
if(!_spender.call(bytes4(bytes32(sha3("receiveApproval(address,uint256,address,bytes)"))), msg.sender, _value, this, _extraData)) { throw; }
return true;
}
} | //name this contract whatever you'd like | LineComment | HippoBohemianToken | function HippoBohemianToken(
) {
balances[msg.sender] = 100000; // Give the creator all initial tokens (100000 for example)
totalSupply = 100000; // Update total supply (100000 for example)
name = "HippoBohemian"; // Set the name for display purposes
decimals = 0; // Amount of decimals for display purposes
symbol = "HPB"; // Set the symbol for display purposes
}
| //human 0.1 standard. Just an arbitrary versioning scheme.
//
// CHANGE THESE VALUES FOR YOUR TOKEN
//
//make sure this function name matches the contract name above. So if you're token is called TutorialToken, make sure the //contract name above is also TutorialToken instead of ERC20Token | LineComment | v0.4.18+commit.9cf6e910 | bzzr://54d62638dd2483dca2133440895cd4111a23aa44082894b649553205c23f007e | {
"func_code_index": [
1167,
1723
]
} | 2,540 |
|
HippoBohemianToken | HippoBohemianToken.sol | 0x1eb553e50aaf4251dd3fc00def6e95b862285d41 | Solidity | HippoBohemianToken | contract HippoBohemianToken is StandardToken {
function () {
//if ether is sent to this address, send it back.
throw;
}
/* Public variables of the token */
/*
NOTE:
The following variables are OPTIONAL vanities. One does not have to include them.
They allow one to customise the token contract & in no way influences the core functionality.
Some wallets/interfaces might not even bother to look at this information.
*/
string public name; //fancy name: eg Simon Bucks
uint8 public decimals; //How many decimals to show. ie. There could 1000 base units with 3 decimals. Meaning 0.980 SBX = 980 base units. It's like comparing 1 wei to 1 ether.
string public symbol; //An identifier: eg SBX
string public version = 'H1.0'; //human 0.1 standard. Just an arbitrary versioning scheme.
//
// CHANGE THESE VALUES FOR YOUR TOKEN
//
//make sure this function name matches the contract name above. So if you're token is called TutorialToken, make sure the //contract name above is also TutorialToken instead of ERC20Token
function HippoBohemianToken(
) {
balances[msg.sender] = 100000; // Give the creator all initial tokens (100000 for example)
totalSupply = 100000; // Update total supply (100000 for example)
name = "HippoBohemian"; // Set the name for display purposes
decimals = 0; // Amount of decimals for display purposes
symbol = "HPB"; // Set the symbol for display purposes
}
/* Approves and then calls the receiving contract */
function approveAndCall(address _spender, uint256 _value, bytes _extraData) returns (bool success) {
allowed[msg.sender][_spender] = _value;
Approval(msg.sender, _spender, _value);
//call the receiveApproval function on the contract you want to be notified. This crafts the function signature manually so one doesn't have to include a contract in here just for this.
//receiveApproval(address _from, uint256 _value, address _tokenContract, bytes _extraData)
//it is assumed that when does this that the call *should* succeed, otherwise one would use vanilla approve instead.
if(!_spender.call(bytes4(bytes32(sha3("receiveApproval(address,uint256,address,bytes)"))), msg.sender, _value, this, _extraData)) { throw; }
return true;
}
} | //name this contract whatever you'd like | LineComment | approveAndCall | function approveAndCall(address _spender, uint256 _value, bytes _extraData) returns (bool success) {
allowed[msg.sender][_spender] = _value;
Approval(msg.sender, _spender, _value);
//call the receiveApproval function on the contract you want to be notified. This crafts the function signature manually so one doesn't have to include a contract in here just for this.
//receiveApproval(address _from, uint256 _value, address _tokenContract, bytes _extraData)
//it is assumed that when does this that the call *should* succeed, otherwise one would use vanilla approve instead.
if(!_spender.call(bytes4(bytes32(sha3("receiveApproval(address,uint256,address,bytes)"))), msg.sender, _value, this, _extraData)) { throw; }
return true;
}
| /* Approves and then calls the receiving contract */ | Comment | v0.4.18+commit.9cf6e910 | bzzr://54d62638dd2483dca2133440895cd4111a23aa44082894b649553205c23f007e | {
"func_code_index": [
1784,
2589
]
} | 2,541 |
|
RPS | RPS.sol | 0x5df4bea3540899a33c76c4d25108f4fe2ca89044 | Solidity | RPS | contract RPS {
enum State { Unrealized, Created, Joined, Ended }
enum Result { Unfinished, Draw, Win, Loss, Forfeit } // From the perspective of player 1
struct Game {
address player1;
address player2;
uint value;
bytes32 hiddenMove1;
uint8 move1; // 0 = not set, 1 = Rock, 2 = Paper, 3 = Scissors
uint8 move2;
uint gameStart;
State state;
Result result;
}
address public owner1;
address public owner2;
uint8 constant feeDivisor = 100;
uint constant revealTime = 7 days; // TODO: dynamic reveal times?
bool paused;
bool expired;
uint gameIdCounter;
uint constant minimumNameLength = 1;
uint constant maximumNameLength = 25;
event NewName(address indexed player, string name);
event Donate(address indexed player, uint amount);
event Deposit(address indexed player, uint amount);
event Withdraw(address indexed player, uint amount);
event GameCreated(address indexed player1, address indexed player2, uint indexed gameId, uint value, bytes32 hiddenMove1);
event GameJoined(address indexed player1, address indexed player2, uint indexed gameId, uint value, uint8 move2, uint gameStart);
event GameEnded(address indexed player1, address indexed player2, uint indexed gameId, uint value, Result result);
mapping(address => uint) public balances;
mapping(address => uint) public totalWon;
mapping(address => uint) public totalLost;
Game [] public games;
mapping(address => string) public playerNames;
mapping(uint => bool) public nameTaken;
mapping(bytes32 => bool) public secretTaken;
modifier onlyOwner { require(msg.sender == owner1 || msg.sender == owner2); _; }
modifier notPaused { require(!paused); _; }
modifier notExpired { require(!expired); _; }
function RPS(address otherOwner) {
owner1 = msg.sender;
owner2 = otherOwner;
paused = true;
}
// UTILIY FUNCTIONS
//
// FOR DOING BORING REPETITIVE TASKS
function getGames() constant internal returns (Game []) {
return games;
}
function totalProfit(address player) constant returns (int) {
if (totalLost[player] > totalWon[player]) {
return -int(totalLost[player] - totalWon[player]);
}
else {
return int(totalWon[player] - totalLost[player]);
}
}
// Fuzzy hash and name validation taken from King of the Ether Throne
// https://github.com/kieranelby/KingOfTheEtherThrone/blob/v1.0/contracts/KingOfTheEtherThrone.sol
function computeNameFuzzyHash(string _name) constant internal
returns (uint fuzzyHash) {
bytes memory nameBytes = bytes(_name);
uint h = 0;
uint len = nameBytes.length;
if (len > maximumNameLength) {
len = maximumNameLength;
}
for (uint i = 0; i < len; i++) {
uint mul = 128;
byte b = nameBytes[i];
uint ub = uint(b);
if (b >= 48 && b <= 57) {
// 0-9
h = h * mul + ub;
} else if (b >= 65 && b <= 90) {
// A-Z
h = h * mul + ub;
} else if (b >= 97 && b <= 122) {
// fold a-z to A-Z
uint upper = ub - 32;
h = h * mul + upper;
} else {
// ignore others
}
}
return h;
}
/// @return True if-and-only-if `_name_` meets the criteria
/// below, or false otherwise:
/// - no fewer than 1 character
/// - no more than 25 characters
/// - no characters other than:
/// - "roman" alphabet letters (A-Z and a-z)
/// - western digits (0-9)
/// - "safe" punctuation: ! ( ) - . _ SPACE
/// - at least one non-punctuation character
/// Note that we deliberately exclude characters which may cause
/// security problems for websites and databases if escaping is
/// not performed correctly, such as < > " and '.
/// Apologies for the lack of non-English language support.
function validateNameInternal(string _name) constant internal
returns (bool allowed) {
bytes memory nameBytes = bytes(_name);
uint lengthBytes = nameBytes.length;
if (lengthBytes < minimumNameLength ||
lengthBytes > maximumNameLength) {
return false;
}
bool foundNonPunctuation = false;
for (uint i = 0; i < lengthBytes; i++) {
byte b = nameBytes[i];
if (
(b >= 48 && b <= 57) || // 0 - 9
(b >= 65 && b <= 90) || // A - Z
(b >= 97 && b <= 122) // a - z
) {
foundNonPunctuation = true;
continue;
}
if (
b == 32 || // space
b == 33 || // !
b == 40 || // (
b == 41 || // )
b == 45 || // -
b == 46 || // .
b == 95 // _
) {
continue;
}
return false;
}
return foundNonPunctuation;
}
/// if you want to donate, please use the donate function
function() { require(false); }
// PLAYER FUNCTIONS
//
// FOR PLAYERS
/// Name must only include upper and lowercase English letters,
/// numbers, and certain characters: ! ( ) - . _ SPACE
/// Function will return false if the name is not valid
/// or if it's too similar to a name that's already taken.
function setName(string name) returns (bool success) {
require (validateNameInternal(name));
uint fuzzyHash = computeNameFuzzyHash(name);
uint oldFuzzyHash;
string storage oldName = playerNames[msg.sender];
bool oldNameEmpty = bytes(oldName).length == 0;
if (nameTaken[fuzzyHash]) {
require(!oldNameEmpty);
oldFuzzyHash = computeNameFuzzyHash(oldName);
require(fuzzyHash == oldFuzzyHash);
}
else {
if (!oldNameEmpty) {
oldFuzzyHash = computeNameFuzzyHash(oldName);
nameTaken[oldFuzzyHash] = false;
}
nameTaken[fuzzyHash] = true;
}
playerNames[msg.sender] = name;
NewName(msg.sender, name);
return true;
}
//{
/// Create a game that may be joined only by the address provided.
/// If no address is provided, the game is open to anyone.
/// Your bet is equal to the value sent together
/// with this transaction. If the game is a draw,
/// your bet will be available for withdrawal.
/// If you win, both bets minus the fee will be send to you.
/// The first argument should be the number
/// of your move (rock: 1, paper: 2, scissors: 3)
/// encrypted with keccak256(uint move, string secret) and
/// save the secret so you can reveal your move
/// after your game is joined.
/// It's very easy to mess up the padding and stuff,
/// so you should just use the website.
//}
function createGame(bytes32 move, uint val, address player2)
payable notPaused notExpired returns (uint gameId) {
deposit();
require(balances[msg.sender] >= val);
require(!secretTaken[move]);
secretTaken[move] = true;
balances[msg.sender] -= val;
gameId = gameIdCounter;
games.push(Game(msg.sender, player2, val, move, 0, 0, 0, State.Created, Result(0)));
GameCreated(msg.sender, player2, gameId, val, move);
gameIdCounter++;
}
function abortGame(uint gameId) notPaused returns (bool success) {
Game storage thisGame = games[gameId];
require(thisGame.player1 == msg.sender);
require(thisGame.state == State.Created);
thisGame.state = State.Ended;
GameEnded(thisGame.player1, thisGame.player2, gameId, thisGame.value, Result(0));
msg.sender.transfer(thisGame.value);
return true;
}
function joinGame(uint gameId, uint8 move) payable notPaused returns (bool success) {
Game storage thisGame = games[gameId];
require(thisGame.state == State.Created);
require(move > 0 && move <= 3);
if (thisGame.player2 == 0x0) {
thisGame.player2 = msg.sender;
}
else {
require(thisGame.player2 == msg.sender);
}
require(thisGame.value == msg.value);
thisGame.gameStart = now;
thisGame.state = State.Joined;
thisGame.move2 = move;
GameJoined(thisGame.player1, thisGame.player2, gameId, thisGame.value, thisGame.move2, thisGame.gameStart);
return true;
}
function revealMove(uint gameId, uint8 move, string secret) notPaused returns (Result result) {
Game storage thisGame = games[gameId];
require(thisGame.state == State.Joined);
require(thisGame.player1 == msg.sender);
require(thisGame.gameStart + revealTime >= now); // It's not too late to reveal
require(thisGame.hiddenMove1 == keccak256(uint(move), secret));
thisGame.move1 = move;
if (move > 0 && move <= 3) {
result = Result(((3 + move - thisGame.move2) % 3) + 1); // It works trust me (it's 'cause of math)
}
else { // Player 1 submitted invalid move
result = Result.Loss;
}
thisGame.state = State.Ended;
address winner;
if (result == Result.Draw) {
balances[thisGame.player1] += thisGame.value;
balances[thisGame.player2] += thisGame.value;
}
else {
if (result == Result.Win) {
winner = thisGame.player1;
totalLost[thisGame.player2] += thisGame.value;
}
else {
winner = thisGame.player2;
totalLost[thisGame.player1] += thisGame.value;
}
uint fee = (thisGame.value) / feeDivisor; // 0.5% fee taken once for each owner
balances[owner1] += fee;
balances[owner2] += fee;
totalWon[winner] += thisGame.value - fee*2;
// No re-entrancy attack is possible because
// the state has already been set to State.Ended
winner.transfer((thisGame.value*2) - fee*2);
}
thisGame.result = result;
GameEnded(thisGame.player1, thisGame.player2, gameId, thisGame.value, result);
}
/// Use this when you know you've lost as player 1 and
/// you don't want to bother with revealing your move.
function forfeitGame(uint gameId) notPaused returns (bool success) {
Game storage thisGame = games[gameId];
require(thisGame.state == State.Joined);
require(thisGame.player1 == msg.sender);
uint fee = (thisGame.value) / feeDivisor; // 0.5% fee taken once for each owner
balances[owner1] += fee;
balances[owner2] += fee;
totalLost[thisGame.player1] += thisGame.value;
totalWon[thisGame.player2] += thisGame.value - fee*2;
thisGame.state = State.Ended;
thisGame.result = Result.Forfeit; // Loss for player 1
GameEnded(thisGame.player1, thisGame.player2, gameId, thisGame.value, thisGame.result);
thisGame.player2.transfer((thisGame.value*2) - fee*2);
return true;
}
function claimGame(uint gameId) notPaused returns (bool success) {
Game storage thisGame = games[gameId];
require(thisGame.state == State.Joined);
require(thisGame.player2 == msg.sender);
require(thisGame.gameStart + revealTime < now); // Player 1 has failed to reveal in time
uint fee = (thisGame.value) / feeDivisor; // 0.5% fee taken once for each owner
balances[owner1] += fee;
balances[owner2] += fee;
totalLost[thisGame.player1] += thisGame.value;
totalWon[thisGame.player2] += thisGame.value - fee*2;
thisGame.state = State.Ended;
thisGame.result = Result.Forfeit; // Loss for player 1
GameEnded(thisGame.player1, thisGame.player2, gameId, thisGame.value, thisGame.result);
thisGame.player2.transfer((thisGame.value*2) - fee*2);
return true;
}
// FUNDING FUNCTIONS
//
// FOR FUNDING
function donate() payable returns (bool success) {
require(msg.value != 0);
balances[owner1] += msg.value/2;
balances[owner2] += msg.value - msg.value/2;
Donate(msg.sender, msg.value);
return true;
}
function deposit() payable returns (bool success) {
require(msg.value != 0);
balances[msg.sender] += msg.value;
Deposit(msg.sender, msg.value);
return true;
}
function withdraw() returns (bool success) {
uint amount = balances[msg.sender];
if (amount == 0) return false;
balances[msg.sender] = 0;
msg.sender.transfer(amount);
Withdraw(msg.sender, amount);
return true;
}
// ADMIN FUNCTIONS
//
// FOR ADMINISTRATING
// Pause all gameplay
function pause(bool pause) onlyOwner {
paused = pause;
}
// Prevent new games from being created
// To be used when switching to a new contract
function expire(bool expire) onlyOwner {
expired = expire;
}
function setOwner1(address newOwner) {
require(msg.sender == owner1);
owner1 = newOwner;
}
function setOwner2(address newOwner) {
require(msg.sender == owner2);
owner2 = newOwner;
}
} | getGames | function getGames() constant internal returns (Game []) {
return games;
}
| // UTILIY FUNCTIONS
//
// FOR DOING BORING REPETITIVE TASKS | LineComment | v0.4.11+commit.68ef5810 | bzzr://6efdff4f2b8d471875b9932830f1cb8516e742dab2186d5ff8f6b7412b67b75e | {
"func_code_index": [
2146,
2238
]
} | 2,542 |
|||
RPS | RPS.sol | 0x5df4bea3540899a33c76c4d25108f4fe2ca89044 | Solidity | RPS | contract RPS {
enum State { Unrealized, Created, Joined, Ended }
enum Result { Unfinished, Draw, Win, Loss, Forfeit } // From the perspective of player 1
struct Game {
address player1;
address player2;
uint value;
bytes32 hiddenMove1;
uint8 move1; // 0 = not set, 1 = Rock, 2 = Paper, 3 = Scissors
uint8 move2;
uint gameStart;
State state;
Result result;
}
address public owner1;
address public owner2;
uint8 constant feeDivisor = 100;
uint constant revealTime = 7 days; // TODO: dynamic reveal times?
bool paused;
bool expired;
uint gameIdCounter;
uint constant minimumNameLength = 1;
uint constant maximumNameLength = 25;
event NewName(address indexed player, string name);
event Donate(address indexed player, uint amount);
event Deposit(address indexed player, uint amount);
event Withdraw(address indexed player, uint amount);
event GameCreated(address indexed player1, address indexed player2, uint indexed gameId, uint value, bytes32 hiddenMove1);
event GameJoined(address indexed player1, address indexed player2, uint indexed gameId, uint value, uint8 move2, uint gameStart);
event GameEnded(address indexed player1, address indexed player2, uint indexed gameId, uint value, Result result);
mapping(address => uint) public balances;
mapping(address => uint) public totalWon;
mapping(address => uint) public totalLost;
Game [] public games;
mapping(address => string) public playerNames;
mapping(uint => bool) public nameTaken;
mapping(bytes32 => bool) public secretTaken;
modifier onlyOwner { require(msg.sender == owner1 || msg.sender == owner2); _; }
modifier notPaused { require(!paused); _; }
modifier notExpired { require(!expired); _; }
function RPS(address otherOwner) {
owner1 = msg.sender;
owner2 = otherOwner;
paused = true;
}
// UTILIY FUNCTIONS
//
// FOR DOING BORING REPETITIVE TASKS
function getGames() constant internal returns (Game []) {
return games;
}
function totalProfit(address player) constant returns (int) {
if (totalLost[player] > totalWon[player]) {
return -int(totalLost[player] - totalWon[player]);
}
else {
return int(totalWon[player] - totalLost[player]);
}
}
// Fuzzy hash and name validation taken from King of the Ether Throne
// https://github.com/kieranelby/KingOfTheEtherThrone/blob/v1.0/contracts/KingOfTheEtherThrone.sol
function computeNameFuzzyHash(string _name) constant internal
returns (uint fuzzyHash) {
bytes memory nameBytes = bytes(_name);
uint h = 0;
uint len = nameBytes.length;
if (len > maximumNameLength) {
len = maximumNameLength;
}
for (uint i = 0; i < len; i++) {
uint mul = 128;
byte b = nameBytes[i];
uint ub = uint(b);
if (b >= 48 && b <= 57) {
// 0-9
h = h * mul + ub;
} else if (b >= 65 && b <= 90) {
// A-Z
h = h * mul + ub;
} else if (b >= 97 && b <= 122) {
// fold a-z to A-Z
uint upper = ub - 32;
h = h * mul + upper;
} else {
// ignore others
}
}
return h;
}
/// @return True if-and-only-if `_name_` meets the criteria
/// below, or false otherwise:
/// - no fewer than 1 character
/// - no more than 25 characters
/// - no characters other than:
/// - "roman" alphabet letters (A-Z and a-z)
/// - western digits (0-9)
/// - "safe" punctuation: ! ( ) - . _ SPACE
/// - at least one non-punctuation character
/// Note that we deliberately exclude characters which may cause
/// security problems for websites and databases if escaping is
/// not performed correctly, such as < > " and '.
/// Apologies for the lack of non-English language support.
function validateNameInternal(string _name) constant internal
returns (bool allowed) {
bytes memory nameBytes = bytes(_name);
uint lengthBytes = nameBytes.length;
if (lengthBytes < minimumNameLength ||
lengthBytes > maximumNameLength) {
return false;
}
bool foundNonPunctuation = false;
for (uint i = 0; i < lengthBytes; i++) {
byte b = nameBytes[i];
if (
(b >= 48 && b <= 57) || // 0 - 9
(b >= 65 && b <= 90) || // A - Z
(b >= 97 && b <= 122) // a - z
) {
foundNonPunctuation = true;
continue;
}
if (
b == 32 || // space
b == 33 || // !
b == 40 || // (
b == 41 || // )
b == 45 || // -
b == 46 || // .
b == 95 // _
) {
continue;
}
return false;
}
return foundNonPunctuation;
}
/// if you want to donate, please use the donate function
function() { require(false); }
// PLAYER FUNCTIONS
//
// FOR PLAYERS
/// Name must only include upper and lowercase English letters,
/// numbers, and certain characters: ! ( ) - . _ SPACE
/// Function will return false if the name is not valid
/// or if it's too similar to a name that's already taken.
function setName(string name) returns (bool success) {
require (validateNameInternal(name));
uint fuzzyHash = computeNameFuzzyHash(name);
uint oldFuzzyHash;
string storage oldName = playerNames[msg.sender];
bool oldNameEmpty = bytes(oldName).length == 0;
if (nameTaken[fuzzyHash]) {
require(!oldNameEmpty);
oldFuzzyHash = computeNameFuzzyHash(oldName);
require(fuzzyHash == oldFuzzyHash);
}
else {
if (!oldNameEmpty) {
oldFuzzyHash = computeNameFuzzyHash(oldName);
nameTaken[oldFuzzyHash] = false;
}
nameTaken[fuzzyHash] = true;
}
playerNames[msg.sender] = name;
NewName(msg.sender, name);
return true;
}
//{
/// Create a game that may be joined only by the address provided.
/// If no address is provided, the game is open to anyone.
/// Your bet is equal to the value sent together
/// with this transaction. If the game is a draw,
/// your bet will be available for withdrawal.
/// If you win, both bets minus the fee will be send to you.
/// The first argument should be the number
/// of your move (rock: 1, paper: 2, scissors: 3)
/// encrypted with keccak256(uint move, string secret) and
/// save the secret so you can reveal your move
/// after your game is joined.
/// It's very easy to mess up the padding and stuff,
/// so you should just use the website.
//}
function createGame(bytes32 move, uint val, address player2)
payable notPaused notExpired returns (uint gameId) {
deposit();
require(balances[msg.sender] >= val);
require(!secretTaken[move]);
secretTaken[move] = true;
balances[msg.sender] -= val;
gameId = gameIdCounter;
games.push(Game(msg.sender, player2, val, move, 0, 0, 0, State.Created, Result(0)));
GameCreated(msg.sender, player2, gameId, val, move);
gameIdCounter++;
}
function abortGame(uint gameId) notPaused returns (bool success) {
Game storage thisGame = games[gameId];
require(thisGame.player1 == msg.sender);
require(thisGame.state == State.Created);
thisGame.state = State.Ended;
GameEnded(thisGame.player1, thisGame.player2, gameId, thisGame.value, Result(0));
msg.sender.transfer(thisGame.value);
return true;
}
function joinGame(uint gameId, uint8 move) payable notPaused returns (bool success) {
Game storage thisGame = games[gameId];
require(thisGame.state == State.Created);
require(move > 0 && move <= 3);
if (thisGame.player2 == 0x0) {
thisGame.player2 = msg.sender;
}
else {
require(thisGame.player2 == msg.sender);
}
require(thisGame.value == msg.value);
thisGame.gameStart = now;
thisGame.state = State.Joined;
thisGame.move2 = move;
GameJoined(thisGame.player1, thisGame.player2, gameId, thisGame.value, thisGame.move2, thisGame.gameStart);
return true;
}
function revealMove(uint gameId, uint8 move, string secret) notPaused returns (Result result) {
Game storage thisGame = games[gameId];
require(thisGame.state == State.Joined);
require(thisGame.player1 == msg.sender);
require(thisGame.gameStart + revealTime >= now); // It's not too late to reveal
require(thisGame.hiddenMove1 == keccak256(uint(move), secret));
thisGame.move1 = move;
if (move > 0 && move <= 3) {
result = Result(((3 + move - thisGame.move2) % 3) + 1); // It works trust me (it's 'cause of math)
}
else { // Player 1 submitted invalid move
result = Result.Loss;
}
thisGame.state = State.Ended;
address winner;
if (result == Result.Draw) {
balances[thisGame.player1] += thisGame.value;
balances[thisGame.player2] += thisGame.value;
}
else {
if (result == Result.Win) {
winner = thisGame.player1;
totalLost[thisGame.player2] += thisGame.value;
}
else {
winner = thisGame.player2;
totalLost[thisGame.player1] += thisGame.value;
}
uint fee = (thisGame.value) / feeDivisor; // 0.5% fee taken once for each owner
balances[owner1] += fee;
balances[owner2] += fee;
totalWon[winner] += thisGame.value - fee*2;
// No re-entrancy attack is possible because
// the state has already been set to State.Ended
winner.transfer((thisGame.value*2) - fee*2);
}
thisGame.result = result;
GameEnded(thisGame.player1, thisGame.player2, gameId, thisGame.value, result);
}
/// Use this when you know you've lost as player 1 and
/// you don't want to bother with revealing your move.
function forfeitGame(uint gameId) notPaused returns (bool success) {
Game storage thisGame = games[gameId];
require(thisGame.state == State.Joined);
require(thisGame.player1 == msg.sender);
uint fee = (thisGame.value) / feeDivisor; // 0.5% fee taken once for each owner
balances[owner1] += fee;
balances[owner2] += fee;
totalLost[thisGame.player1] += thisGame.value;
totalWon[thisGame.player2] += thisGame.value - fee*2;
thisGame.state = State.Ended;
thisGame.result = Result.Forfeit; // Loss for player 1
GameEnded(thisGame.player1, thisGame.player2, gameId, thisGame.value, thisGame.result);
thisGame.player2.transfer((thisGame.value*2) - fee*2);
return true;
}
function claimGame(uint gameId) notPaused returns (bool success) {
Game storage thisGame = games[gameId];
require(thisGame.state == State.Joined);
require(thisGame.player2 == msg.sender);
require(thisGame.gameStart + revealTime < now); // Player 1 has failed to reveal in time
uint fee = (thisGame.value) / feeDivisor; // 0.5% fee taken once for each owner
balances[owner1] += fee;
balances[owner2] += fee;
totalLost[thisGame.player1] += thisGame.value;
totalWon[thisGame.player2] += thisGame.value - fee*2;
thisGame.state = State.Ended;
thisGame.result = Result.Forfeit; // Loss for player 1
GameEnded(thisGame.player1, thisGame.player2, gameId, thisGame.value, thisGame.result);
thisGame.player2.transfer((thisGame.value*2) - fee*2);
return true;
}
// FUNDING FUNCTIONS
//
// FOR FUNDING
function donate() payable returns (bool success) {
require(msg.value != 0);
balances[owner1] += msg.value/2;
balances[owner2] += msg.value - msg.value/2;
Donate(msg.sender, msg.value);
return true;
}
function deposit() payable returns (bool success) {
require(msg.value != 0);
balances[msg.sender] += msg.value;
Deposit(msg.sender, msg.value);
return true;
}
function withdraw() returns (bool success) {
uint amount = balances[msg.sender];
if (amount == 0) return false;
balances[msg.sender] = 0;
msg.sender.transfer(amount);
Withdraw(msg.sender, amount);
return true;
}
// ADMIN FUNCTIONS
//
// FOR ADMINISTRATING
// Pause all gameplay
function pause(bool pause) onlyOwner {
paused = pause;
}
// Prevent new games from being created
// To be used when switching to a new contract
function expire(bool expire) onlyOwner {
expired = expire;
}
function setOwner1(address newOwner) {
require(msg.sender == owner1);
owner1 = newOwner;
}
function setOwner2(address newOwner) {
require(msg.sender == owner2);
owner2 = newOwner;
}
} | computeNameFuzzyHash | function computeNameFuzzyHash(string _name) constant internal
returns (uint fuzzyHash) {
bytes memory nameBytes = bytes(_name);
uint h = 0;
uint len = nameBytes.length;
if (len > maximumNameLength) {
len = maximumNameLength;
}
for (uint i = 0; i < len; i++) {
uint mul = 128;
byte b = nameBytes[i];
uint ub = uint(b);
if (b >= 48 && b <= 57) {
// 0-9
h = h * mul + ub;
} else if (b >= 65 && b <= 90) {
// A-Z
h = h * mul + ub;
} else if (b >= 97 && b <= 122) {
// fold a-z to A-Z
uint upper = ub - 32;
h = h * mul + upper;
} else {
// ignore others
}
}
return h;
}
| // Fuzzy hash and name validation taken from King of the Ether Throne
// https://github.com/kieranelby/KingOfTheEtherThrone/blob/v1.0/contracts/KingOfTheEtherThrone.sol | LineComment | v0.4.11+commit.68ef5810 | bzzr://6efdff4f2b8d471875b9932830f1cb8516e742dab2186d5ff8f6b7412b67b75e | {
"func_code_index": [
2722,
3626
]
} | 2,543 |
|||
RPS | RPS.sol | 0x5df4bea3540899a33c76c4d25108f4fe2ca89044 | Solidity | RPS | contract RPS {
enum State { Unrealized, Created, Joined, Ended }
enum Result { Unfinished, Draw, Win, Loss, Forfeit } // From the perspective of player 1
struct Game {
address player1;
address player2;
uint value;
bytes32 hiddenMove1;
uint8 move1; // 0 = not set, 1 = Rock, 2 = Paper, 3 = Scissors
uint8 move2;
uint gameStart;
State state;
Result result;
}
address public owner1;
address public owner2;
uint8 constant feeDivisor = 100;
uint constant revealTime = 7 days; // TODO: dynamic reveal times?
bool paused;
bool expired;
uint gameIdCounter;
uint constant minimumNameLength = 1;
uint constant maximumNameLength = 25;
event NewName(address indexed player, string name);
event Donate(address indexed player, uint amount);
event Deposit(address indexed player, uint amount);
event Withdraw(address indexed player, uint amount);
event GameCreated(address indexed player1, address indexed player2, uint indexed gameId, uint value, bytes32 hiddenMove1);
event GameJoined(address indexed player1, address indexed player2, uint indexed gameId, uint value, uint8 move2, uint gameStart);
event GameEnded(address indexed player1, address indexed player2, uint indexed gameId, uint value, Result result);
mapping(address => uint) public balances;
mapping(address => uint) public totalWon;
mapping(address => uint) public totalLost;
Game [] public games;
mapping(address => string) public playerNames;
mapping(uint => bool) public nameTaken;
mapping(bytes32 => bool) public secretTaken;
modifier onlyOwner { require(msg.sender == owner1 || msg.sender == owner2); _; }
modifier notPaused { require(!paused); _; }
modifier notExpired { require(!expired); _; }
function RPS(address otherOwner) {
owner1 = msg.sender;
owner2 = otherOwner;
paused = true;
}
// UTILIY FUNCTIONS
//
// FOR DOING BORING REPETITIVE TASKS
function getGames() constant internal returns (Game []) {
return games;
}
function totalProfit(address player) constant returns (int) {
if (totalLost[player] > totalWon[player]) {
return -int(totalLost[player] - totalWon[player]);
}
else {
return int(totalWon[player] - totalLost[player]);
}
}
// Fuzzy hash and name validation taken from King of the Ether Throne
// https://github.com/kieranelby/KingOfTheEtherThrone/blob/v1.0/contracts/KingOfTheEtherThrone.sol
function computeNameFuzzyHash(string _name) constant internal
returns (uint fuzzyHash) {
bytes memory nameBytes = bytes(_name);
uint h = 0;
uint len = nameBytes.length;
if (len > maximumNameLength) {
len = maximumNameLength;
}
for (uint i = 0; i < len; i++) {
uint mul = 128;
byte b = nameBytes[i];
uint ub = uint(b);
if (b >= 48 && b <= 57) {
// 0-9
h = h * mul + ub;
} else if (b >= 65 && b <= 90) {
// A-Z
h = h * mul + ub;
} else if (b >= 97 && b <= 122) {
// fold a-z to A-Z
uint upper = ub - 32;
h = h * mul + upper;
} else {
// ignore others
}
}
return h;
}
/// @return True if-and-only-if `_name_` meets the criteria
/// below, or false otherwise:
/// - no fewer than 1 character
/// - no more than 25 characters
/// - no characters other than:
/// - "roman" alphabet letters (A-Z and a-z)
/// - western digits (0-9)
/// - "safe" punctuation: ! ( ) - . _ SPACE
/// - at least one non-punctuation character
/// Note that we deliberately exclude characters which may cause
/// security problems for websites and databases if escaping is
/// not performed correctly, such as < > " and '.
/// Apologies for the lack of non-English language support.
function validateNameInternal(string _name) constant internal
returns (bool allowed) {
bytes memory nameBytes = bytes(_name);
uint lengthBytes = nameBytes.length;
if (lengthBytes < minimumNameLength ||
lengthBytes > maximumNameLength) {
return false;
}
bool foundNonPunctuation = false;
for (uint i = 0; i < lengthBytes; i++) {
byte b = nameBytes[i];
if (
(b >= 48 && b <= 57) || // 0 - 9
(b >= 65 && b <= 90) || // A - Z
(b >= 97 && b <= 122) // a - z
) {
foundNonPunctuation = true;
continue;
}
if (
b == 32 || // space
b == 33 || // !
b == 40 || // (
b == 41 || // )
b == 45 || // -
b == 46 || // .
b == 95 // _
) {
continue;
}
return false;
}
return foundNonPunctuation;
}
/// if you want to donate, please use the donate function
function() { require(false); }
// PLAYER FUNCTIONS
//
// FOR PLAYERS
/// Name must only include upper and lowercase English letters,
/// numbers, and certain characters: ! ( ) - . _ SPACE
/// Function will return false if the name is not valid
/// or if it's too similar to a name that's already taken.
function setName(string name) returns (bool success) {
require (validateNameInternal(name));
uint fuzzyHash = computeNameFuzzyHash(name);
uint oldFuzzyHash;
string storage oldName = playerNames[msg.sender];
bool oldNameEmpty = bytes(oldName).length == 0;
if (nameTaken[fuzzyHash]) {
require(!oldNameEmpty);
oldFuzzyHash = computeNameFuzzyHash(oldName);
require(fuzzyHash == oldFuzzyHash);
}
else {
if (!oldNameEmpty) {
oldFuzzyHash = computeNameFuzzyHash(oldName);
nameTaken[oldFuzzyHash] = false;
}
nameTaken[fuzzyHash] = true;
}
playerNames[msg.sender] = name;
NewName(msg.sender, name);
return true;
}
//{
/// Create a game that may be joined only by the address provided.
/// If no address is provided, the game is open to anyone.
/// Your bet is equal to the value sent together
/// with this transaction. If the game is a draw,
/// your bet will be available for withdrawal.
/// If you win, both bets minus the fee will be send to you.
/// The first argument should be the number
/// of your move (rock: 1, paper: 2, scissors: 3)
/// encrypted with keccak256(uint move, string secret) and
/// save the secret so you can reveal your move
/// after your game is joined.
/// It's very easy to mess up the padding and stuff,
/// so you should just use the website.
//}
function createGame(bytes32 move, uint val, address player2)
payable notPaused notExpired returns (uint gameId) {
deposit();
require(balances[msg.sender] >= val);
require(!secretTaken[move]);
secretTaken[move] = true;
balances[msg.sender] -= val;
gameId = gameIdCounter;
games.push(Game(msg.sender, player2, val, move, 0, 0, 0, State.Created, Result(0)));
GameCreated(msg.sender, player2, gameId, val, move);
gameIdCounter++;
}
function abortGame(uint gameId) notPaused returns (bool success) {
Game storage thisGame = games[gameId];
require(thisGame.player1 == msg.sender);
require(thisGame.state == State.Created);
thisGame.state = State.Ended;
GameEnded(thisGame.player1, thisGame.player2, gameId, thisGame.value, Result(0));
msg.sender.transfer(thisGame.value);
return true;
}
function joinGame(uint gameId, uint8 move) payable notPaused returns (bool success) {
Game storage thisGame = games[gameId];
require(thisGame.state == State.Created);
require(move > 0 && move <= 3);
if (thisGame.player2 == 0x0) {
thisGame.player2 = msg.sender;
}
else {
require(thisGame.player2 == msg.sender);
}
require(thisGame.value == msg.value);
thisGame.gameStart = now;
thisGame.state = State.Joined;
thisGame.move2 = move;
GameJoined(thisGame.player1, thisGame.player2, gameId, thisGame.value, thisGame.move2, thisGame.gameStart);
return true;
}
function revealMove(uint gameId, uint8 move, string secret) notPaused returns (Result result) {
Game storage thisGame = games[gameId];
require(thisGame.state == State.Joined);
require(thisGame.player1 == msg.sender);
require(thisGame.gameStart + revealTime >= now); // It's not too late to reveal
require(thisGame.hiddenMove1 == keccak256(uint(move), secret));
thisGame.move1 = move;
if (move > 0 && move <= 3) {
result = Result(((3 + move - thisGame.move2) % 3) + 1); // It works trust me (it's 'cause of math)
}
else { // Player 1 submitted invalid move
result = Result.Loss;
}
thisGame.state = State.Ended;
address winner;
if (result == Result.Draw) {
balances[thisGame.player1] += thisGame.value;
balances[thisGame.player2] += thisGame.value;
}
else {
if (result == Result.Win) {
winner = thisGame.player1;
totalLost[thisGame.player2] += thisGame.value;
}
else {
winner = thisGame.player2;
totalLost[thisGame.player1] += thisGame.value;
}
uint fee = (thisGame.value) / feeDivisor; // 0.5% fee taken once for each owner
balances[owner1] += fee;
balances[owner2] += fee;
totalWon[winner] += thisGame.value - fee*2;
// No re-entrancy attack is possible because
// the state has already been set to State.Ended
winner.transfer((thisGame.value*2) - fee*2);
}
thisGame.result = result;
GameEnded(thisGame.player1, thisGame.player2, gameId, thisGame.value, result);
}
/// Use this when you know you've lost as player 1 and
/// you don't want to bother with revealing your move.
function forfeitGame(uint gameId) notPaused returns (bool success) {
Game storage thisGame = games[gameId];
require(thisGame.state == State.Joined);
require(thisGame.player1 == msg.sender);
uint fee = (thisGame.value) / feeDivisor; // 0.5% fee taken once for each owner
balances[owner1] += fee;
balances[owner2] += fee;
totalLost[thisGame.player1] += thisGame.value;
totalWon[thisGame.player2] += thisGame.value - fee*2;
thisGame.state = State.Ended;
thisGame.result = Result.Forfeit; // Loss for player 1
GameEnded(thisGame.player1, thisGame.player2, gameId, thisGame.value, thisGame.result);
thisGame.player2.transfer((thisGame.value*2) - fee*2);
return true;
}
function claimGame(uint gameId) notPaused returns (bool success) {
Game storage thisGame = games[gameId];
require(thisGame.state == State.Joined);
require(thisGame.player2 == msg.sender);
require(thisGame.gameStart + revealTime < now); // Player 1 has failed to reveal in time
uint fee = (thisGame.value) / feeDivisor; // 0.5% fee taken once for each owner
balances[owner1] += fee;
balances[owner2] += fee;
totalLost[thisGame.player1] += thisGame.value;
totalWon[thisGame.player2] += thisGame.value - fee*2;
thisGame.state = State.Ended;
thisGame.result = Result.Forfeit; // Loss for player 1
GameEnded(thisGame.player1, thisGame.player2, gameId, thisGame.value, thisGame.result);
thisGame.player2.transfer((thisGame.value*2) - fee*2);
return true;
}
// FUNDING FUNCTIONS
//
// FOR FUNDING
function donate() payable returns (bool success) {
require(msg.value != 0);
balances[owner1] += msg.value/2;
balances[owner2] += msg.value - msg.value/2;
Donate(msg.sender, msg.value);
return true;
}
function deposit() payable returns (bool success) {
require(msg.value != 0);
balances[msg.sender] += msg.value;
Deposit(msg.sender, msg.value);
return true;
}
function withdraw() returns (bool success) {
uint amount = balances[msg.sender];
if (amount == 0) return false;
balances[msg.sender] = 0;
msg.sender.transfer(amount);
Withdraw(msg.sender, amount);
return true;
}
// ADMIN FUNCTIONS
//
// FOR ADMINISTRATING
// Pause all gameplay
function pause(bool pause) onlyOwner {
paused = pause;
}
// Prevent new games from being created
// To be used when switching to a new contract
function expire(bool expire) onlyOwner {
expired = expire;
}
function setOwner1(address newOwner) {
require(msg.sender == owner1);
owner1 = newOwner;
}
function setOwner2(address newOwner) {
require(msg.sender == owner2);
owner2 = newOwner;
}
} | validateNameInternal | function validateNameInternal(string _name) constant internal
returns (bool allowed) {
bytes memory nameBytes = bytes(_name);
uint lengthBytes = nameBytes.length;
if (lengthBytes < minimumNameLength ||
lengthBytes > maximumNameLength) {
return false;
}
bool foundNonPunctuation = false;
for (uint i = 0; i < lengthBytes; i++) {
byte b = nameBytes[i];
if (
(b >= 48 && b <= 57) || // 0 - 9
(b >= 65 && b <= 90) || // A - Z
(b >= 97 && b <= 122) // a - z
) {
foundNonPunctuation = true;
continue;
}
if (
b == 32 || // space
b == 33 || // !
b == 40 || // (
b == 41 || // )
b == 45 || // -
b == 46 || // .
b == 95 // _
) {
continue;
}
return false;
}
return foundNonPunctuation;
}
| /// @return True if-and-only-if `_name_` meets the criteria
/// below, or false otherwise:
/// - no fewer than 1 character
/// - no more than 25 characters
/// - no characters other than:
/// - "roman" alphabet letters (A-Z and a-z)
/// - western digits (0-9)
/// - "safe" punctuation: ! ( ) - . _ SPACE
/// - at least one non-punctuation character
/// Note that we deliberately exclude characters which may cause
/// security problems for websites and databases if escaping is
/// not performed correctly, such as < > " and '.
/// Apologies for the lack of non-English language support. | NatSpecSingleLine | v0.4.11+commit.68ef5810 | bzzr://6efdff4f2b8d471875b9932830f1cb8516e742dab2186d5ff8f6b7412b67b75e | {
"func_code_index": [
4300,
5419
]
} | 2,544 |
|||
RPS | RPS.sol | 0x5df4bea3540899a33c76c4d25108f4fe2ca89044 | Solidity | RPS | contract RPS {
enum State { Unrealized, Created, Joined, Ended }
enum Result { Unfinished, Draw, Win, Loss, Forfeit } // From the perspective of player 1
struct Game {
address player1;
address player2;
uint value;
bytes32 hiddenMove1;
uint8 move1; // 0 = not set, 1 = Rock, 2 = Paper, 3 = Scissors
uint8 move2;
uint gameStart;
State state;
Result result;
}
address public owner1;
address public owner2;
uint8 constant feeDivisor = 100;
uint constant revealTime = 7 days; // TODO: dynamic reveal times?
bool paused;
bool expired;
uint gameIdCounter;
uint constant minimumNameLength = 1;
uint constant maximumNameLength = 25;
event NewName(address indexed player, string name);
event Donate(address indexed player, uint amount);
event Deposit(address indexed player, uint amount);
event Withdraw(address indexed player, uint amount);
event GameCreated(address indexed player1, address indexed player2, uint indexed gameId, uint value, bytes32 hiddenMove1);
event GameJoined(address indexed player1, address indexed player2, uint indexed gameId, uint value, uint8 move2, uint gameStart);
event GameEnded(address indexed player1, address indexed player2, uint indexed gameId, uint value, Result result);
mapping(address => uint) public balances;
mapping(address => uint) public totalWon;
mapping(address => uint) public totalLost;
Game [] public games;
mapping(address => string) public playerNames;
mapping(uint => bool) public nameTaken;
mapping(bytes32 => bool) public secretTaken;
modifier onlyOwner { require(msg.sender == owner1 || msg.sender == owner2); _; }
modifier notPaused { require(!paused); _; }
modifier notExpired { require(!expired); _; }
function RPS(address otherOwner) {
owner1 = msg.sender;
owner2 = otherOwner;
paused = true;
}
// UTILIY FUNCTIONS
//
// FOR DOING BORING REPETITIVE TASKS
function getGames() constant internal returns (Game []) {
return games;
}
function totalProfit(address player) constant returns (int) {
if (totalLost[player] > totalWon[player]) {
return -int(totalLost[player] - totalWon[player]);
}
else {
return int(totalWon[player] - totalLost[player]);
}
}
// Fuzzy hash and name validation taken from King of the Ether Throne
// https://github.com/kieranelby/KingOfTheEtherThrone/blob/v1.0/contracts/KingOfTheEtherThrone.sol
function computeNameFuzzyHash(string _name) constant internal
returns (uint fuzzyHash) {
bytes memory nameBytes = bytes(_name);
uint h = 0;
uint len = nameBytes.length;
if (len > maximumNameLength) {
len = maximumNameLength;
}
for (uint i = 0; i < len; i++) {
uint mul = 128;
byte b = nameBytes[i];
uint ub = uint(b);
if (b >= 48 && b <= 57) {
// 0-9
h = h * mul + ub;
} else if (b >= 65 && b <= 90) {
// A-Z
h = h * mul + ub;
} else if (b >= 97 && b <= 122) {
// fold a-z to A-Z
uint upper = ub - 32;
h = h * mul + upper;
} else {
// ignore others
}
}
return h;
}
/// @return True if-and-only-if `_name_` meets the criteria
/// below, or false otherwise:
/// - no fewer than 1 character
/// - no more than 25 characters
/// - no characters other than:
/// - "roman" alphabet letters (A-Z and a-z)
/// - western digits (0-9)
/// - "safe" punctuation: ! ( ) - . _ SPACE
/// - at least one non-punctuation character
/// Note that we deliberately exclude characters which may cause
/// security problems for websites and databases if escaping is
/// not performed correctly, such as < > " and '.
/// Apologies for the lack of non-English language support.
function validateNameInternal(string _name) constant internal
returns (bool allowed) {
bytes memory nameBytes = bytes(_name);
uint lengthBytes = nameBytes.length;
if (lengthBytes < minimumNameLength ||
lengthBytes > maximumNameLength) {
return false;
}
bool foundNonPunctuation = false;
for (uint i = 0; i < lengthBytes; i++) {
byte b = nameBytes[i];
if (
(b >= 48 && b <= 57) || // 0 - 9
(b >= 65 && b <= 90) || // A - Z
(b >= 97 && b <= 122) // a - z
) {
foundNonPunctuation = true;
continue;
}
if (
b == 32 || // space
b == 33 || // !
b == 40 || // (
b == 41 || // )
b == 45 || // -
b == 46 || // .
b == 95 // _
) {
continue;
}
return false;
}
return foundNonPunctuation;
}
/// if you want to donate, please use the donate function
function() { require(false); }
// PLAYER FUNCTIONS
//
// FOR PLAYERS
/// Name must only include upper and lowercase English letters,
/// numbers, and certain characters: ! ( ) - . _ SPACE
/// Function will return false if the name is not valid
/// or if it's too similar to a name that's already taken.
function setName(string name) returns (bool success) {
require (validateNameInternal(name));
uint fuzzyHash = computeNameFuzzyHash(name);
uint oldFuzzyHash;
string storage oldName = playerNames[msg.sender];
bool oldNameEmpty = bytes(oldName).length == 0;
if (nameTaken[fuzzyHash]) {
require(!oldNameEmpty);
oldFuzzyHash = computeNameFuzzyHash(oldName);
require(fuzzyHash == oldFuzzyHash);
}
else {
if (!oldNameEmpty) {
oldFuzzyHash = computeNameFuzzyHash(oldName);
nameTaken[oldFuzzyHash] = false;
}
nameTaken[fuzzyHash] = true;
}
playerNames[msg.sender] = name;
NewName(msg.sender, name);
return true;
}
//{
/// Create a game that may be joined only by the address provided.
/// If no address is provided, the game is open to anyone.
/// Your bet is equal to the value sent together
/// with this transaction. If the game is a draw,
/// your bet will be available for withdrawal.
/// If you win, both bets minus the fee will be send to you.
/// The first argument should be the number
/// of your move (rock: 1, paper: 2, scissors: 3)
/// encrypted with keccak256(uint move, string secret) and
/// save the secret so you can reveal your move
/// after your game is joined.
/// It's very easy to mess up the padding and stuff,
/// so you should just use the website.
//}
function createGame(bytes32 move, uint val, address player2)
payable notPaused notExpired returns (uint gameId) {
deposit();
require(balances[msg.sender] >= val);
require(!secretTaken[move]);
secretTaken[move] = true;
balances[msg.sender] -= val;
gameId = gameIdCounter;
games.push(Game(msg.sender, player2, val, move, 0, 0, 0, State.Created, Result(0)));
GameCreated(msg.sender, player2, gameId, val, move);
gameIdCounter++;
}
function abortGame(uint gameId) notPaused returns (bool success) {
Game storage thisGame = games[gameId];
require(thisGame.player1 == msg.sender);
require(thisGame.state == State.Created);
thisGame.state = State.Ended;
GameEnded(thisGame.player1, thisGame.player2, gameId, thisGame.value, Result(0));
msg.sender.transfer(thisGame.value);
return true;
}
function joinGame(uint gameId, uint8 move) payable notPaused returns (bool success) {
Game storage thisGame = games[gameId];
require(thisGame.state == State.Created);
require(move > 0 && move <= 3);
if (thisGame.player2 == 0x0) {
thisGame.player2 = msg.sender;
}
else {
require(thisGame.player2 == msg.sender);
}
require(thisGame.value == msg.value);
thisGame.gameStart = now;
thisGame.state = State.Joined;
thisGame.move2 = move;
GameJoined(thisGame.player1, thisGame.player2, gameId, thisGame.value, thisGame.move2, thisGame.gameStart);
return true;
}
function revealMove(uint gameId, uint8 move, string secret) notPaused returns (Result result) {
Game storage thisGame = games[gameId];
require(thisGame.state == State.Joined);
require(thisGame.player1 == msg.sender);
require(thisGame.gameStart + revealTime >= now); // It's not too late to reveal
require(thisGame.hiddenMove1 == keccak256(uint(move), secret));
thisGame.move1 = move;
if (move > 0 && move <= 3) {
result = Result(((3 + move - thisGame.move2) % 3) + 1); // It works trust me (it's 'cause of math)
}
else { // Player 1 submitted invalid move
result = Result.Loss;
}
thisGame.state = State.Ended;
address winner;
if (result == Result.Draw) {
balances[thisGame.player1] += thisGame.value;
balances[thisGame.player2] += thisGame.value;
}
else {
if (result == Result.Win) {
winner = thisGame.player1;
totalLost[thisGame.player2] += thisGame.value;
}
else {
winner = thisGame.player2;
totalLost[thisGame.player1] += thisGame.value;
}
uint fee = (thisGame.value) / feeDivisor; // 0.5% fee taken once for each owner
balances[owner1] += fee;
balances[owner2] += fee;
totalWon[winner] += thisGame.value - fee*2;
// No re-entrancy attack is possible because
// the state has already been set to State.Ended
winner.transfer((thisGame.value*2) - fee*2);
}
thisGame.result = result;
GameEnded(thisGame.player1, thisGame.player2, gameId, thisGame.value, result);
}
/// Use this when you know you've lost as player 1 and
/// you don't want to bother with revealing your move.
function forfeitGame(uint gameId) notPaused returns (bool success) {
Game storage thisGame = games[gameId];
require(thisGame.state == State.Joined);
require(thisGame.player1 == msg.sender);
uint fee = (thisGame.value) / feeDivisor; // 0.5% fee taken once for each owner
balances[owner1] += fee;
balances[owner2] += fee;
totalLost[thisGame.player1] += thisGame.value;
totalWon[thisGame.player2] += thisGame.value - fee*2;
thisGame.state = State.Ended;
thisGame.result = Result.Forfeit; // Loss for player 1
GameEnded(thisGame.player1, thisGame.player2, gameId, thisGame.value, thisGame.result);
thisGame.player2.transfer((thisGame.value*2) - fee*2);
return true;
}
function claimGame(uint gameId) notPaused returns (bool success) {
Game storage thisGame = games[gameId];
require(thisGame.state == State.Joined);
require(thisGame.player2 == msg.sender);
require(thisGame.gameStart + revealTime < now); // Player 1 has failed to reveal in time
uint fee = (thisGame.value) / feeDivisor; // 0.5% fee taken once for each owner
balances[owner1] += fee;
balances[owner2] += fee;
totalLost[thisGame.player1] += thisGame.value;
totalWon[thisGame.player2] += thisGame.value - fee*2;
thisGame.state = State.Ended;
thisGame.result = Result.Forfeit; // Loss for player 1
GameEnded(thisGame.player1, thisGame.player2, gameId, thisGame.value, thisGame.result);
thisGame.player2.transfer((thisGame.value*2) - fee*2);
return true;
}
// FUNDING FUNCTIONS
//
// FOR FUNDING
function donate() payable returns (bool success) {
require(msg.value != 0);
balances[owner1] += msg.value/2;
balances[owner2] += msg.value - msg.value/2;
Donate(msg.sender, msg.value);
return true;
}
function deposit() payable returns (bool success) {
require(msg.value != 0);
balances[msg.sender] += msg.value;
Deposit(msg.sender, msg.value);
return true;
}
function withdraw() returns (bool success) {
uint amount = balances[msg.sender];
if (amount == 0) return false;
balances[msg.sender] = 0;
msg.sender.transfer(amount);
Withdraw(msg.sender, amount);
return true;
}
// ADMIN FUNCTIONS
//
// FOR ADMINISTRATING
// Pause all gameplay
function pause(bool pause) onlyOwner {
paused = pause;
}
// Prevent new games from being created
// To be used when switching to a new contract
function expire(bool expire) onlyOwner {
expired = expire;
}
function setOwner1(address newOwner) {
require(msg.sender == owner1);
owner1 = newOwner;
}
function setOwner2(address newOwner) {
require(msg.sender == owner2);
owner2 = newOwner;
}
} | function() { require(false); }
| /// if you want to donate, please use the donate function | NatSpecSingleLine | v0.4.11+commit.68ef5810 | bzzr://6efdff4f2b8d471875b9932830f1cb8516e742dab2186d5ff8f6b7412b67b75e | {
"func_code_index": [
5495,
5530
]
} | 2,545 |
||||
RPS | RPS.sol | 0x5df4bea3540899a33c76c4d25108f4fe2ca89044 | Solidity | RPS | contract RPS {
enum State { Unrealized, Created, Joined, Ended }
enum Result { Unfinished, Draw, Win, Loss, Forfeit } // From the perspective of player 1
struct Game {
address player1;
address player2;
uint value;
bytes32 hiddenMove1;
uint8 move1; // 0 = not set, 1 = Rock, 2 = Paper, 3 = Scissors
uint8 move2;
uint gameStart;
State state;
Result result;
}
address public owner1;
address public owner2;
uint8 constant feeDivisor = 100;
uint constant revealTime = 7 days; // TODO: dynamic reveal times?
bool paused;
bool expired;
uint gameIdCounter;
uint constant minimumNameLength = 1;
uint constant maximumNameLength = 25;
event NewName(address indexed player, string name);
event Donate(address indexed player, uint amount);
event Deposit(address indexed player, uint amount);
event Withdraw(address indexed player, uint amount);
event GameCreated(address indexed player1, address indexed player2, uint indexed gameId, uint value, bytes32 hiddenMove1);
event GameJoined(address indexed player1, address indexed player2, uint indexed gameId, uint value, uint8 move2, uint gameStart);
event GameEnded(address indexed player1, address indexed player2, uint indexed gameId, uint value, Result result);
mapping(address => uint) public balances;
mapping(address => uint) public totalWon;
mapping(address => uint) public totalLost;
Game [] public games;
mapping(address => string) public playerNames;
mapping(uint => bool) public nameTaken;
mapping(bytes32 => bool) public secretTaken;
modifier onlyOwner { require(msg.sender == owner1 || msg.sender == owner2); _; }
modifier notPaused { require(!paused); _; }
modifier notExpired { require(!expired); _; }
function RPS(address otherOwner) {
owner1 = msg.sender;
owner2 = otherOwner;
paused = true;
}
// UTILIY FUNCTIONS
//
// FOR DOING BORING REPETITIVE TASKS
function getGames() constant internal returns (Game []) {
return games;
}
function totalProfit(address player) constant returns (int) {
if (totalLost[player] > totalWon[player]) {
return -int(totalLost[player] - totalWon[player]);
}
else {
return int(totalWon[player] - totalLost[player]);
}
}
// Fuzzy hash and name validation taken from King of the Ether Throne
// https://github.com/kieranelby/KingOfTheEtherThrone/blob/v1.0/contracts/KingOfTheEtherThrone.sol
function computeNameFuzzyHash(string _name) constant internal
returns (uint fuzzyHash) {
bytes memory nameBytes = bytes(_name);
uint h = 0;
uint len = nameBytes.length;
if (len > maximumNameLength) {
len = maximumNameLength;
}
for (uint i = 0; i < len; i++) {
uint mul = 128;
byte b = nameBytes[i];
uint ub = uint(b);
if (b >= 48 && b <= 57) {
// 0-9
h = h * mul + ub;
} else if (b >= 65 && b <= 90) {
// A-Z
h = h * mul + ub;
} else if (b >= 97 && b <= 122) {
// fold a-z to A-Z
uint upper = ub - 32;
h = h * mul + upper;
} else {
// ignore others
}
}
return h;
}
/// @return True if-and-only-if `_name_` meets the criteria
/// below, or false otherwise:
/// - no fewer than 1 character
/// - no more than 25 characters
/// - no characters other than:
/// - "roman" alphabet letters (A-Z and a-z)
/// - western digits (0-9)
/// - "safe" punctuation: ! ( ) - . _ SPACE
/// - at least one non-punctuation character
/// Note that we deliberately exclude characters which may cause
/// security problems for websites and databases if escaping is
/// not performed correctly, such as < > " and '.
/// Apologies for the lack of non-English language support.
function validateNameInternal(string _name) constant internal
returns (bool allowed) {
bytes memory nameBytes = bytes(_name);
uint lengthBytes = nameBytes.length;
if (lengthBytes < minimumNameLength ||
lengthBytes > maximumNameLength) {
return false;
}
bool foundNonPunctuation = false;
for (uint i = 0; i < lengthBytes; i++) {
byte b = nameBytes[i];
if (
(b >= 48 && b <= 57) || // 0 - 9
(b >= 65 && b <= 90) || // A - Z
(b >= 97 && b <= 122) // a - z
) {
foundNonPunctuation = true;
continue;
}
if (
b == 32 || // space
b == 33 || // !
b == 40 || // (
b == 41 || // )
b == 45 || // -
b == 46 || // .
b == 95 // _
) {
continue;
}
return false;
}
return foundNonPunctuation;
}
/// if you want to donate, please use the donate function
function() { require(false); }
// PLAYER FUNCTIONS
//
// FOR PLAYERS
/// Name must only include upper and lowercase English letters,
/// numbers, and certain characters: ! ( ) - . _ SPACE
/// Function will return false if the name is not valid
/// or if it's too similar to a name that's already taken.
function setName(string name) returns (bool success) {
require (validateNameInternal(name));
uint fuzzyHash = computeNameFuzzyHash(name);
uint oldFuzzyHash;
string storage oldName = playerNames[msg.sender];
bool oldNameEmpty = bytes(oldName).length == 0;
if (nameTaken[fuzzyHash]) {
require(!oldNameEmpty);
oldFuzzyHash = computeNameFuzzyHash(oldName);
require(fuzzyHash == oldFuzzyHash);
}
else {
if (!oldNameEmpty) {
oldFuzzyHash = computeNameFuzzyHash(oldName);
nameTaken[oldFuzzyHash] = false;
}
nameTaken[fuzzyHash] = true;
}
playerNames[msg.sender] = name;
NewName(msg.sender, name);
return true;
}
//{
/// Create a game that may be joined only by the address provided.
/// If no address is provided, the game is open to anyone.
/// Your bet is equal to the value sent together
/// with this transaction. If the game is a draw,
/// your bet will be available for withdrawal.
/// If you win, both bets minus the fee will be send to you.
/// The first argument should be the number
/// of your move (rock: 1, paper: 2, scissors: 3)
/// encrypted with keccak256(uint move, string secret) and
/// save the secret so you can reveal your move
/// after your game is joined.
/// It's very easy to mess up the padding and stuff,
/// so you should just use the website.
//}
function createGame(bytes32 move, uint val, address player2)
payable notPaused notExpired returns (uint gameId) {
deposit();
require(balances[msg.sender] >= val);
require(!secretTaken[move]);
secretTaken[move] = true;
balances[msg.sender] -= val;
gameId = gameIdCounter;
games.push(Game(msg.sender, player2, val, move, 0, 0, 0, State.Created, Result(0)));
GameCreated(msg.sender, player2, gameId, val, move);
gameIdCounter++;
}
function abortGame(uint gameId) notPaused returns (bool success) {
Game storage thisGame = games[gameId];
require(thisGame.player1 == msg.sender);
require(thisGame.state == State.Created);
thisGame.state = State.Ended;
GameEnded(thisGame.player1, thisGame.player2, gameId, thisGame.value, Result(0));
msg.sender.transfer(thisGame.value);
return true;
}
function joinGame(uint gameId, uint8 move) payable notPaused returns (bool success) {
Game storage thisGame = games[gameId];
require(thisGame.state == State.Created);
require(move > 0 && move <= 3);
if (thisGame.player2 == 0x0) {
thisGame.player2 = msg.sender;
}
else {
require(thisGame.player2 == msg.sender);
}
require(thisGame.value == msg.value);
thisGame.gameStart = now;
thisGame.state = State.Joined;
thisGame.move2 = move;
GameJoined(thisGame.player1, thisGame.player2, gameId, thisGame.value, thisGame.move2, thisGame.gameStart);
return true;
}
function revealMove(uint gameId, uint8 move, string secret) notPaused returns (Result result) {
Game storage thisGame = games[gameId];
require(thisGame.state == State.Joined);
require(thisGame.player1 == msg.sender);
require(thisGame.gameStart + revealTime >= now); // It's not too late to reveal
require(thisGame.hiddenMove1 == keccak256(uint(move), secret));
thisGame.move1 = move;
if (move > 0 && move <= 3) {
result = Result(((3 + move - thisGame.move2) % 3) + 1); // It works trust me (it's 'cause of math)
}
else { // Player 1 submitted invalid move
result = Result.Loss;
}
thisGame.state = State.Ended;
address winner;
if (result == Result.Draw) {
balances[thisGame.player1] += thisGame.value;
balances[thisGame.player2] += thisGame.value;
}
else {
if (result == Result.Win) {
winner = thisGame.player1;
totalLost[thisGame.player2] += thisGame.value;
}
else {
winner = thisGame.player2;
totalLost[thisGame.player1] += thisGame.value;
}
uint fee = (thisGame.value) / feeDivisor; // 0.5% fee taken once for each owner
balances[owner1] += fee;
balances[owner2] += fee;
totalWon[winner] += thisGame.value - fee*2;
// No re-entrancy attack is possible because
// the state has already been set to State.Ended
winner.transfer((thisGame.value*2) - fee*2);
}
thisGame.result = result;
GameEnded(thisGame.player1, thisGame.player2, gameId, thisGame.value, result);
}
/// Use this when you know you've lost as player 1 and
/// you don't want to bother with revealing your move.
function forfeitGame(uint gameId) notPaused returns (bool success) {
Game storage thisGame = games[gameId];
require(thisGame.state == State.Joined);
require(thisGame.player1 == msg.sender);
uint fee = (thisGame.value) / feeDivisor; // 0.5% fee taken once for each owner
balances[owner1] += fee;
balances[owner2] += fee;
totalLost[thisGame.player1] += thisGame.value;
totalWon[thisGame.player2] += thisGame.value - fee*2;
thisGame.state = State.Ended;
thisGame.result = Result.Forfeit; // Loss for player 1
GameEnded(thisGame.player1, thisGame.player2, gameId, thisGame.value, thisGame.result);
thisGame.player2.transfer((thisGame.value*2) - fee*2);
return true;
}
function claimGame(uint gameId) notPaused returns (bool success) {
Game storage thisGame = games[gameId];
require(thisGame.state == State.Joined);
require(thisGame.player2 == msg.sender);
require(thisGame.gameStart + revealTime < now); // Player 1 has failed to reveal in time
uint fee = (thisGame.value) / feeDivisor; // 0.5% fee taken once for each owner
balances[owner1] += fee;
balances[owner2] += fee;
totalLost[thisGame.player1] += thisGame.value;
totalWon[thisGame.player2] += thisGame.value - fee*2;
thisGame.state = State.Ended;
thisGame.result = Result.Forfeit; // Loss for player 1
GameEnded(thisGame.player1, thisGame.player2, gameId, thisGame.value, thisGame.result);
thisGame.player2.transfer((thisGame.value*2) - fee*2);
return true;
}
// FUNDING FUNCTIONS
//
// FOR FUNDING
function donate() payable returns (bool success) {
require(msg.value != 0);
balances[owner1] += msg.value/2;
balances[owner2] += msg.value - msg.value/2;
Donate(msg.sender, msg.value);
return true;
}
function deposit() payable returns (bool success) {
require(msg.value != 0);
balances[msg.sender] += msg.value;
Deposit(msg.sender, msg.value);
return true;
}
function withdraw() returns (bool success) {
uint amount = balances[msg.sender];
if (amount == 0) return false;
balances[msg.sender] = 0;
msg.sender.transfer(amount);
Withdraw(msg.sender, amount);
return true;
}
// ADMIN FUNCTIONS
//
// FOR ADMINISTRATING
// Pause all gameplay
function pause(bool pause) onlyOwner {
paused = pause;
}
// Prevent new games from being created
// To be used when switching to a new contract
function expire(bool expire) onlyOwner {
expired = expire;
}
function setOwner1(address newOwner) {
require(msg.sender == owner1);
owner1 = newOwner;
}
function setOwner2(address newOwner) {
require(msg.sender == owner2);
owner2 = newOwner;
}
} | setName | function setName(string name) returns (bool success) {
require (validateNameInternal(name));
uint fuzzyHash = computeNameFuzzyHash(name);
uint oldFuzzyHash;
string storage oldName = playerNames[msg.sender];
bool oldNameEmpty = bytes(oldName).length == 0;
if (nameTaken[fuzzyHash]) {
require(!oldNameEmpty);
oldFuzzyHash = computeNameFuzzyHash(oldName);
require(fuzzyHash == oldFuzzyHash);
}
else {
if (!oldNameEmpty) {
oldFuzzyHash = computeNameFuzzyHash(oldName);
nameTaken[oldFuzzyHash] = false;
}
nameTaken[fuzzyHash] = true;
}
playerNames[msg.sender] = name;
NewName(msg.sender, name);
return true;
}
| /// Name must only include upper and lowercase English letters,
/// numbers, and certain characters: ! ( ) - . _ SPACE
/// Function will return false if the name is not valid
/// or if it's too similar to a name that's already taken. | NatSpecSingleLine | v0.4.11+commit.68ef5810 | bzzr://6efdff4f2b8d471875b9932830f1cb8516e742dab2186d5ff8f6b7412b67b75e | {
"func_code_index": [
5850,
6686
]
} | 2,546 |
|||
RPS | RPS.sol | 0x5df4bea3540899a33c76c4d25108f4fe2ca89044 | Solidity | RPS | contract RPS {
enum State { Unrealized, Created, Joined, Ended }
enum Result { Unfinished, Draw, Win, Loss, Forfeit } // From the perspective of player 1
struct Game {
address player1;
address player2;
uint value;
bytes32 hiddenMove1;
uint8 move1; // 0 = not set, 1 = Rock, 2 = Paper, 3 = Scissors
uint8 move2;
uint gameStart;
State state;
Result result;
}
address public owner1;
address public owner2;
uint8 constant feeDivisor = 100;
uint constant revealTime = 7 days; // TODO: dynamic reveal times?
bool paused;
bool expired;
uint gameIdCounter;
uint constant minimumNameLength = 1;
uint constant maximumNameLength = 25;
event NewName(address indexed player, string name);
event Donate(address indexed player, uint amount);
event Deposit(address indexed player, uint amount);
event Withdraw(address indexed player, uint amount);
event GameCreated(address indexed player1, address indexed player2, uint indexed gameId, uint value, bytes32 hiddenMove1);
event GameJoined(address indexed player1, address indexed player2, uint indexed gameId, uint value, uint8 move2, uint gameStart);
event GameEnded(address indexed player1, address indexed player2, uint indexed gameId, uint value, Result result);
mapping(address => uint) public balances;
mapping(address => uint) public totalWon;
mapping(address => uint) public totalLost;
Game [] public games;
mapping(address => string) public playerNames;
mapping(uint => bool) public nameTaken;
mapping(bytes32 => bool) public secretTaken;
modifier onlyOwner { require(msg.sender == owner1 || msg.sender == owner2); _; }
modifier notPaused { require(!paused); _; }
modifier notExpired { require(!expired); _; }
function RPS(address otherOwner) {
owner1 = msg.sender;
owner2 = otherOwner;
paused = true;
}
// UTILIY FUNCTIONS
//
// FOR DOING BORING REPETITIVE TASKS
function getGames() constant internal returns (Game []) {
return games;
}
function totalProfit(address player) constant returns (int) {
if (totalLost[player] > totalWon[player]) {
return -int(totalLost[player] - totalWon[player]);
}
else {
return int(totalWon[player] - totalLost[player]);
}
}
// Fuzzy hash and name validation taken from King of the Ether Throne
// https://github.com/kieranelby/KingOfTheEtherThrone/blob/v1.0/contracts/KingOfTheEtherThrone.sol
function computeNameFuzzyHash(string _name) constant internal
returns (uint fuzzyHash) {
bytes memory nameBytes = bytes(_name);
uint h = 0;
uint len = nameBytes.length;
if (len > maximumNameLength) {
len = maximumNameLength;
}
for (uint i = 0; i < len; i++) {
uint mul = 128;
byte b = nameBytes[i];
uint ub = uint(b);
if (b >= 48 && b <= 57) {
// 0-9
h = h * mul + ub;
} else if (b >= 65 && b <= 90) {
// A-Z
h = h * mul + ub;
} else if (b >= 97 && b <= 122) {
// fold a-z to A-Z
uint upper = ub - 32;
h = h * mul + upper;
} else {
// ignore others
}
}
return h;
}
/// @return True if-and-only-if `_name_` meets the criteria
/// below, or false otherwise:
/// - no fewer than 1 character
/// - no more than 25 characters
/// - no characters other than:
/// - "roman" alphabet letters (A-Z and a-z)
/// - western digits (0-9)
/// - "safe" punctuation: ! ( ) - . _ SPACE
/// - at least one non-punctuation character
/// Note that we deliberately exclude characters which may cause
/// security problems for websites and databases if escaping is
/// not performed correctly, such as < > " and '.
/// Apologies for the lack of non-English language support.
function validateNameInternal(string _name) constant internal
returns (bool allowed) {
bytes memory nameBytes = bytes(_name);
uint lengthBytes = nameBytes.length;
if (lengthBytes < minimumNameLength ||
lengthBytes > maximumNameLength) {
return false;
}
bool foundNonPunctuation = false;
for (uint i = 0; i < lengthBytes; i++) {
byte b = nameBytes[i];
if (
(b >= 48 && b <= 57) || // 0 - 9
(b >= 65 && b <= 90) || // A - Z
(b >= 97 && b <= 122) // a - z
) {
foundNonPunctuation = true;
continue;
}
if (
b == 32 || // space
b == 33 || // !
b == 40 || // (
b == 41 || // )
b == 45 || // -
b == 46 || // .
b == 95 // _
) {
continue;
}
return false;
}
return foundNonPunctuation;
}
/// if you want to donate, please use the donate function
function() { require(false); }
// PLAYER FUNCTIONS
//
// FOR PLAYERS
/// Name must only include upper and lowercase English letters,
/// numbers, and certain characters: ! ( ) - . _ SPACE
/// Function will return false if the name is not valid
/// or if it's too similar to a name that's already taken.
function setName(string name) returns (bool success) {
require (validateNameInternal(name));
uint fuzzyHash = computeNameFuzzyHash(name);
uint oldFuzzyHash;
string storage oldName = playerNames[msg.sender];
bool oldNameEmpty = bytes(oldName).length == 0;
if (nameTaken[fuzzyHash]) {
require(!oldNameEmpty);
oldFuzzyHash = computeNameFuzzyHash(oldName);
require(fuzzyHash == oldFuzzyHash);
}
else {
if (!oldNameEmpty) {
oldFuzzyHash = computeNameFuzzyHash(oldName);
nameTaken[oldFuzzyHash] = false;
}
nameTaken[fuzzyHash] = true;
}
playerNames[msg.sender] = name;
NewName(msg.sender, name);
return true;
}
//{
/// Create a game that may be joined only by the address provided.
/// If no address is provided, the game is open to anyone.
/// Your bet is equal to the value sent together
/// with this transaction. If the game is a draw,
/// your bet will be available for withdrawal.
/// If you win, both bets minus the fee will be send to you.
/// The first argument should be the number
/// of your move (rock: 1, paper: 2, scissors: 3)
/// encrypted with keccak256(uint move, string secret) and
/// save the secret so you can reveal your move
/// after your game is joined.
/// It's very easy to mess up the padding and stuff,
/// so you should just use the website.
//}
function createGame(bytes32 move, uint val, address player2)
payable notPaused notExpired returns (uint gameId) {
deposit();
require(balances[msg.sender] >= val);
require(!secretTaken[move]);
secretTaken[move] = true;
balances[msg.sender] -= val;
gameId = gameIdCounter;
games.push(Game(msg.sender, player2, val, move, 0, 0, 0, State.Created, Result(0)));
GameCreated(msg.sender, player2, gameId, val, move);
gameIdCounter++;
}
function abortGame(uint gameId) notPaused returns (bool success) {
Game storage thisGame = games[gameId];
require(thisGame.player1 == msg.sender);
require(thisGame.state == State.Created);
thisGame.state = State.Ended;
GameEnded(thisGame.player1, thisGame.player2, gameId, thisGame.value, Result(0));
msg.sender.transfer(thisGame.value);
return true;
}
function joinGame(uint gameId, uint8 move) payable notPaused returns (bool success) {
Game storage thisGame = games[gameId];
require(thisGame.state == State.Created);
require(move > 0 && move <= 3);
if (thisGame.player2 == 0x0) {
thisGame.player2 = msg.sender;
}
else {
require(thisGame.player2 == msg.sender);
}
require(thisGame.value == msg.value);
thisGame.gameStart = now;
thisGame.state = State.Joined;
thisGame.move2 = move;
GameJoined(thisGame.player1, thisGame.player2, gameId, thisGame.value, thisGame.move2, thisGame.gameStart);
return true;
}
function revealMove(uint gameId, uint8 move, string secret) notPaused returns (Result result) {
Game storage thisGame = games[gameId];
require(thisGame.state == State.Joined);
require(thisGame.player1 == msg.sender);
require(thisGame.gameStart + revealTime >= now); // It's not too late to reveal
require(thisGame.hiddenMove1 == keccak256(uint(move), secret));
thisGame.move1 = move;
if (move > 0 && move <= 3) {
result = Result(((3 + move - thisGame.move2) % 3) + 1); // It works trust me (it's 'cause of math)
}
else { // Player 1 submitted invalid move
result = Result.Loss;
}
thisGame.state = State.Ended;
address winner;
if (result == Result.Draw) {
balances[thisGame.player1] += thisGame.value;
balances[thisGame.player2] += thisGame.value;
}
else {
if (result == Result.Win) {
winner = thisGame.player1;
totalLost[thisGame.player2] += thisGame.value;
}
else {
winner = thisGame.player2;
totalLost[thisGame.player1] += thisGame.value;
}
uint fee = (thisGame.value) / feeDivisor; // 0.5% fee taken once for each owner
balances[owner1] += fee;
balances[owner2] += fee;
totalWon[winner] += thisGame.value - fee*2;
// No re-entrancy attack is possible because
// the state has already been set to State.Ended
winner.transfer((thisGame.value*2) - fee*2);
}
thisGame.result = result;
GameEnded(thisGame.player1, thisGame.player2, gameId, thisGame.value, result);
}
/// Use this when you know you've lost as player 1 and
/// you don't want to bother with revealing your move.
function forfeitGame(uint gameId) notPaused returns (bool success) {
Game storage thisGame = games[gameId];
require(thisGame.state == State.Joined);
require(thisGame.player1 == msg.sender);
uint fee = (thisGame.value) / feeDivisor; // 0.5% fee taken once for each owner
balances[owner1] += fee;
balances[owner2] += fee;
totalLost[thisGame.player1] += thisGame.value;
totalWon[thisGame.player2] += thisGame.value - fee*2;
thisGame.state = State.Ended;
thisGame.result = Result.Forfeit; // Loss for player 1
GameEnded(thisGame.player1, thisGame.player2, gameId, thisGame.value, thisGame.result);
thisGame.player2.transfer((thisGame.value*2) - fee*2);
return true;
}
function claimGame(uint gameId) notPaused returns (bool success) {
Game storage thisGame = games[gameId];
require(thisGame.state == State.Joined);
require(thisGame.player2 == msg.sender);
require(thisGame.gameStart + revealTime < now); // Player 1 has failed to reveal in time
uint fee = (thisGame.value) / feeDivisor; // 0.5% fee taken once for each owner
balances[owner1] += fee;
balances[owner2] += fee;
totalLost[thisGame.player1] += thisGame.value;
totalWon[thisGame.player2] += thisGame.value - fee*2;
thisGame.state = State.Ended;
thisGame.result = Result.Forfeit; // Loss for player 1
GameEnded(thisGame.player1, thisGame.player2, gameId, thisGame.value, thisGame.result);
thisGame.player2.transfer((thisGame.value*2) - fee*2);
return true;
}
// FUNDING FUNCTIONS
//
// FOR FUNDING
function donate() payable returns (bool success) {
require(msg.value != 0);
balances[owner1] += msg.value/2;
balances[owner2] += msg.value - msg.value/2;
Donate(msg.sender, msg.value);
return true;
}
function deposit() payable returns (bool success) {
require(msg.value != 0);
balances[msg.sender] += msg.value;
Deposit(msg.sender, msg.value);
return true;
}
function withdraw() returns (bool success) {
uint amount = balances[msg.sender];
if (amount == 0) return false;
balances[msg.sender] = 0;
msg.sender.transfer(amount);
Withdraw(msg.sender, amount);
return true;
}
// ADMIN FUNCTIONS
//
// FOR ADMINISTRATING
// Pause all gameplay
function pause(bool pause) onlyOwner {
paused = pause;
}
// Prevent new games from being created
// To be used when switching to a new contract
function expire(bool expire) onlyOwner {
expired = expire;
}
function setOwner1(address newOwner) {
require(msg.sender == owner1);
owner1 = newOwner;
}
function setOwner2(address newOwner) {
require(msg.sender == owner2);
owner2 = newOwner;
}
} | createGame | function createGame(bytes32 move, uint val, address player2)
payable notPaused notExpired returns (uint gameId) {
deposit();
require(balances[msg.sender] >= val);
require(!secretTaken[move]);
secretTaken[move] = true;
balances[msg.sender] -= val;
gameId = gameIdCounter;
games.push(Game(msg.sender, player2, val, move, 0, 0, 0, State.Created, Result(0)));
GameCreated(msg.sender, player2, gameId, val, move);
gameIdCounter++;
}
| //} | LineComment | v0.4.11+commit.68ef5810 | bzzr://6efdff4f2b8d471875b9932830f1cb8516e742dab2186d5ff8f6b7412b67b75e | {
"func_code_index": [
7434,
7959
]
} | 2,547 |
|||
RPS | RPS.sol | 0x5df4bea3540899a33c76c4d25108f4fe2ca89044 | Solidity | RPS | contract RPS {
enum State { Unrealized, Created, Joined, Ended }
enum Result { Unfinished, Draw, Win, Loss, Forfeit } // From the perspective of player 1
struct Game {
address player1;
address player2;
uint value;
bytes32 hiddenMove1;
uint8 move1; // 0 = not set, 1 = Rock, 2 = Paper, 3 = Scissors
uint8 move2;
uint gameStart;
State state;
Result result;
}
address public owner1;
address public owner2;
uint8 constant feeDivisor = 100;
uint constant revealTime = 7 days; // TODO: dynamic reveal times?
bool paused;
bool expired;
uint gameIdCounter;
uint constant minimumNameLength = 1;
uint constant maximumNameLength = 25;
event NewName(address indexed player, string name);
event Donate(address indexed player, uint amount);
event Deposit(address indexed player, uint amount);
event Withdraw(address indexed player, uint amount);
event GameCreated(address indexed player1, address indexed player2, uint indexed gameId, uint value, bytes32 hiddenMove1);
event GameJoined(address indexed player1, address indexed player2, uint indexed gameId, uint value, uint8 move2, uint gameStart);
event GameEnded(address indexed player1, address indexed player2, uint indexed gameId, uint value, Result result);
mapping(address => uint) public balances;
mapping(address => uint) public totalWon;
mapping(address => uint) public totalLost;
Game [] public games;
mapping(address => string) public playerNames;
mapping(uint => bool) public nameTaken;
mapping(bytes32 => bool) public secretTaken;
modifier onlyOwner { require(msg.sender == owner1 || msg.sender == owner2); _; }
modifier notPaused { require(!paused); _; }
modifier notExpired { require(!expired); _; }
function RPS(address otherOwner) {
owner1 = msg.sender;
owner2 = otherOwner;
paused = true;
}
// UTILIY FUNCTIONS
//
// FOR DOING BORING REPETITIVE TASKS
function getGames() constant internal returns (Game []) {
return games;
}
function totalProfit(address player) constant returns (int) {
if (totalLost[player] > totalWon[player]) {
return -int(totalLost[player] - totalWon[player]);
}
else {
return int(totalWon[player] - totalLost[player]);
}
}
// Fuzzy hash and name validation taken from King of the Ether Throne
// https://github.com/kieranelby/KingOfTheEtherThrone/blob/v1.0/contracts/KingOfTheEtherThrone.sol
function computeNameFuzzyHash(string _name) constant internal
returns (uint fuzzyHash) {
bytes memory nameBytes = bytes(_name);
uint h = 0;
uint len = nameBytes.length;
if (len > maximumNameLength) {
len = maximumNameLength;
}
for (uint i = 0; i < len; i++) {
uint mul = 128;
byte b = nameBytes[i];
uint ub = uint(b);
if (b >= 48 && b <= 57) {
// 0-9
h = h * mul + ub;
} else if (b >= 65 && b <= 90) {
// A-Z
h = h * mul + ub;
} else if (b >= 97 && b <= 122) {
// fold a-z to A-Z
uint upper = ub - 32;
h = h * mul + upper;
} else {
// ignore others
}
}
return h;
}
/// @return True if-and-only-if `_name_` meets the criteria
/// below, or false otherwise:
/// - no fewer than 1 character
/// - no more than 25 characters
/// - no characters other than:
/// - "roman" alphabet letters (A-Z and a-z)
/// - western digits (0-9)
/// - "safe" punctuation: ! ( ) - . _ SPACE
/// - at least one non-punctuation character
/// Note that we deliberately exclude characters which may cause
/// security problems for websites and databases if escaping is
/// not performed correctly, such as < > " and '.
/// Apologies for the lack of non-English language support.
function validateNameInternal(string _name) constant internal
returns (bool allowed) {
bytes memory nameBytes = bytes(_name);
uint lengthBytes = nameBytes.length;
if (lengthBytes < minimumNameLength ||
lengthBytes > maximumNameLength) {
return false;
}
bool foundNonPunctuation = false;
for (uint i = 0; i < lengthBytes; i++) {
byte b = nameBytes[i];
if (
(b >= 48 && b <= 57) || // 0 - 9
(b >= 65 && b <= 90) || // A - Z
(b >= 97 && b <= 122) // a - z
) {
foundNonPunctuation = true;
continue;
}
if (
b == 32 || // space
b == 33 || // !
b == 40 || // (
b == 41 || // )
b == 45 || // -
b == 46 || // .
b == 95 // _
) {
continue;
}
return false;
}
return foundNonPunctuation;
}
/// if you want to donate, please use the donate function
function() { require(false); }
// PLAYER FUNCTIONS
//
// FOR PLAYERS
/// Name must only include upper and lowercase English letters,
/// numbers, and certain characters: ! ( ) - . _ SPACE
/// Function will return false if the name is not valid
/// or if it's too similar to a name that's already taken.
function setName(string name) returns (bool success) {
require (validateNameInternal(name));
uint fuzzyHash = computeNameFuzzyHash(name);
uint oldFuzzyHash;
string storage oldName = playerNames[msg.sender];
bool oldNameEmpty = bytes(oldName).length == 0;
if (nameTaken[fuzzyHash]) {
require(!oldNameEmpty);
oldFuzzyHash = computeNameFuzzyHash(oldName);
require(fuzzyHash == oldFuzzyHash);
}
else {
if (!oldNameEmpty) {
oldFuzzyHash = computeNameFuzzyHash(oldName);
nameTaken[oldFuzzyHash] = false;
}
nameTaken[fuzzyHash] = true;
}
playerNames[msg.sender] = name;
NewName(msg.sender, name);
return true;
}
//{
/// Create a game that may be joined only by the address provided.
/// If no address is provided, the game is open to anyone.
/// Your bet is equal to the value sent together
/// with this transaction. If the game is a draw,
/// your bet will be available for withdrawal.
/// If you win, both bets minus the fee will be send to you.
/// The first argument should be the number
/// of your move (rock: 1, paper: 2, scissors: 3)
/// encrypted with keccak256(uint move, string secret) and
/// save the secret so you can reveal your move
/// after your game is joined.
/// It's very easy to mess up the padding and stuff,
/// so you should just use the website.
//}
function createGame(bytes32 move, uint val, address player2)
payable notPaused notExpired returns (uint gameId) {
deposit();
require(balances[msg.sender] >= val);
require(!secretTaken[move]);
secretTaken[move] = true;
balances[msg.sender] -= val;
gameId = gameIdCounter;
games.push(Game(msg.sender, player2, val, move, 0, 0, 0, State.Created, Result(0)));
GameCreated(msg.sender, player2, gameId, val, move);
gameIdCounter++;
}
function abortGame(uint gameId) notPaused returns (bool success) {
Game storage thisGame = games[gameId];
require(thisGame.player1 == msg.sender);
require(thisGame.state == State.Created);
thisGame.state = State.Ended;
GameEnded(thisGame.player1, thisGame.player2, gameId, thisGame.value, Result(0));
msg.sender.transfer(thisGame.value);
return true;
}
function joinGame(uint gameId, uint8 move) payable notPaused returns (bool success) {
Game storage thisGame = games[gameId];
require(thisGame.state == State.Created);
require(move > 0 && move <= 3);
if (thisGame.player2 == 0x0) {
thisGame.player2 = msg.sender;
}
else {
require(thisGame.player2 == msg.sender);
}
require(thisGame.value == msg.value);
thisGame.gameStart = now;
thisGame.state = State.Joined;
thisGame.move2 = move;
GameJoined(thisGame.player1, thisGame.player2, gameId, thisGame.value, thisGame.move2, thisGame.gameStart);
return true;
}
function revealMove(uint gameId, uint8 move, string secret) notPaused returns (Result result) {
Game storage thisGame = games[gameId];
require(thisGame.state == State.Joined);
require(thisGame.player1 == msg.sender);
require(thisGame.gameStart + revealTime >= now); // It's not too late to reveal
require(thisGame.hiddenMove1 == keccak256(uint(move), secret));
thisGame.move1 = move;
if (move > 0 && move <= 3) {
result = Result(((3 + move - thisGame.move2) % 3) + 1); // It works trust me (it's 'cause of math)
}
else { // Player 1 submitted invalid move
result = Result.Loss;
}
thisGame.state = State.Ended;
address winner;
if (result == Result.Draw) {
balances[thisGame.player1] += thisGame.value;
balances[thisGame.player2] += thisGame.value;
}
else {
if (result == Result.Win) {
winner = thisGame.player1;
totalLost[thisGame.player2] += thisGame.value;
}
else {
winner = thisGame.player2;
totalLost[thisGame.player1] += thisGame.value;
}
uint fee = (thisGame.value) / feeDivisor; // 0.5% fee taken once for each owner
balances[owner1] += fee;
balances[owner2] += fee;
totalWon[winner] += thisGame.value - fee*2;
// No re-entrancy attack is possible because
// the state has already been set to State.Ended
winner.transfer((thisGame.value*2) - fee*2);
}
thisGame.result = result;
GameEnded(thisGame.player1, thisGame.player2, gameId, thisGame.value, result);
}
/// Use this when you know you've lost as player 1 and
/// you don't want to bother with revealing your move.
function forfeitGame(uint gameId) notPaused returns (bool success) {
Game storage thisGame = games[gameId];
require(thisGame.state == State.Joined);
require(thisGame.player1 == msg.sender);
uint fee = (thisGame.value) / feeDivisor; // 0.5% fee taken once for each owner
balances[owner1] += fee;
balances[owner2] += fee;
totalLost[thisGame.player1] += thisGame.value;
totalWon[thisGame.player2] += thisGame.value - fee*2;
thisGame.state = State.Ended;
thisGame.result = Result.Forfeit; // Loss for player 1
GameEnded(thisGame.player1, thisGame.player2, gameId, thisGame.value, thisGame.result);
thisGame.player2.transfer((thisGame.value*2) - fee*2);
return true;
}
function claimGame(uint gameId) notPaused returns (bool success) {
Game storage thisGame = games[gameId];
require(thisGame.state == State.Joined);
require(thisGame.player2 == msg.sender);
require(thisGame.gameStart + revealTime < now); // Player 1 has failed to reveal in time
uint fee = (thisGame.value) / feeDivisor; // 0.5% fee taken once for each owner
balances[owner1] += fee;
balances[owner2] += fee;
totalLost[thisGame.player1] += thisGame.value;
totalWon[thisGame.player2] += thisGame.value - fee*2;
thisGame.state = State.Ended;
thisGame.result = Result.Forfeit; // Loss for player 1
GameEnded(thisGame.player1, thisGame.player2, gameId, thisGame.value, thisGame.result);
thisGame.player2.transfer((thisGame.value*2) - fee*2);
return true;
}
// FUNDING FUNCTIONS
//
// FOR FUNDING
function donate() payable returns (bool success) {
require(msg.value != 0);
balances[owner1] += msg.value/2;
balances[owner2] += msg.value - msg.value/2;
Donate(msg.sender, msg.value);
return true;
}
function deposit() payable returns (bool success) {
require(msg.value != 0);
balances[msg.sender] += msg.value;
Deposit(msg.sender, msg.value);
return true;
}
function withdraw() returns (bool success) {
uint amount = balances[msg.sender];
if (amount == 0) return false;
balances[msg.sender] = 0;
msg.sender.transfer(amount);
Withdraw(msg.sender, amount);
return true;
}
// ADMIN FUNCTIONS
//
// FOR ADMINISTRATING
// Pause all gameplay
function pause(bool pause) onlyOwner {
paused = pause;
}
// Prevent new games from being created
// To be used when switching to a new contract
function expire(bool expire) onlyOwner {
expired = expire;
}
function setOwner1(address newOwner) {
require(msg.sender == owner1);
owner1 = newOwner;
}
function setOwner2(address newOwner) {
require(msg.sender == owner2);
owner2 = newOwner;
}
} | forfeitGame | function forfeitGame(uint gameId) notPaused returns (bool success) {
Game storage thisGame = games[gameId];
require(thisGame.state == State.Joined);
require(thisGame.player1 == msg.sender);
uint fee = (thisGame.value) / feeDivisor; // 0.5% fee taken once for each owner
balances[owner1] += fee;
balances[owner2] += fee;
totalLost[thisGame.player1] += thisGame.value;
totalWon[thisGame.player2] += thisGame.value - fee*2;
thisGame.state = State.Ended;
thisGame.result = Result.Forfeit; // Loss for player 1
GameEnded(thisGame.player1, thisGame.player2, gameId, thisGame.value, thisGame.result);
thisGame.player2.transfer((thisGame.value*2) - fee*2);
return true;
}
| /// Use this when you know you've lost as player 1 and
/// you don't want to bother with revealing your move. | NatSpecSingleLine | v0.4.11+commit.68ef5810 | bzzr://6efdff4f2b8d471875b9932830f1cb8516e742dab2186d5ff8f6b7412b67b75e | {
"func_code_index": [
11045,
11857
]
} | 2,548 |
|||
RPS | RPS.sol | 0x5df4bea3540899a33c76c4d25108f4fe2ca89044 | Solidity | RPS | contract RPS {
enum State { Unrealized, Created, Joined, Ended }
enum Result { Unfinished, Draw, Win, Loss, Forfeit } // From the perspective of player 1
struct Game {
address player1;
address player2;
uint value;
bytes32 hiddenMove1;
uint8 move1; // 0 = not set, 1 = Rock, 2 = Paper, 3 = Scissors
uint8 move2;
uint gameStart;
State state;
Result result;
}
address public owner1;
address public owner2;
uint8 constant feeDivisor = 100;
uint constant revealTime = 7 days; // TODO: dynamic reveal times?
bool paused;
bool expired;
uint gameIdCounter;
uint constant minimumNameLength = 1;
uint constant maximumNameLength = 25;
event NewName(address indexed player, string name);
event Donate(address indexed player, uint amount);
event Deposit(address indexed player, uint amount);
event Withdraw(address indexed player, uint amount);
event GameCreated(address indexed player1, address indexed player2, uint indexed gameId, uint value, bytes32 hiddenMove1);
event GameJoined(address indexed player1, address indexed player2, uint indexed gameId, uint value, uint8 move2, uint gameStart);
event GameEnded(address indexed player1, address indexed player2, uint indexed gameId, uint value, Result result);
mapping(address => uint) public balances;
mapping(address => uint) public totalWon;
mapping(address => uint) public totalLost;
Game [] public games;
mapping(address => string) public playerNames;
mapping(uint => bool) public nameTaken;
mapping(bytes32 => bool) public secretTaken;
modifier onlyOwner { require(msg.sender == owner1 || msg.sender == owner2); _; }
modifier notPaused { require(!paused); _; }
modifier notExpired { require(!expired); _; }
function RPS(address otherOwner) {
owner1 = msg.sender;
owner2 = otherOwner;
paused = true;
}
// UTILIY FUNCTIONS
//
// FOR DOING BORING REPETITIVE TASKS
function getGames() constant internal returns (Game []) {
return games;
}
function totalProfit(address player) constant returns (int) {
if (totalLost[player] > totalWon[player]) {
return -int(totalLost[player] - totalWon[player]);
}
else {
return int(totalWon[player] - totalLost[player]);
}
}
// Fuzzy hash and name validation taken from King of the Ether Throne
// https://github.com/kieranelby/KingOfTheEtherThrone/blob/v1.0/contracts/KingOfTheEtherThrone.sol
function computeNameFuzzyHash(string _name) constant internal
returns (uint fuzzyHash) {
bytes memory nameBytes = bytes(_name);
uint h = 0;
uint len = nameBytes.length;
if (len > maximumNameLength) {
len = maximumNameLength;
}
for (uint i = 0; i < len; i++) {
uint mul = 128;
byte b = nameBytes[i];
uint ub = uint(b);
if (b >= 48 && b <= 57) {
// 0-9
h = h * mul + ub;
} else if (b >= 65 && b <= 90) {
// A-Z
h = h * mul + ub;
} else if (b >= 97 && b <= 122) {
// fold a-z to A-Z
uint upper = ub - 32;
h = h * mul + upper;
} else {
// ignore others
}
}
return h;
}
/// @return True if-and-only-if `_name_` meets the criteria
/// below, or false otherwise:
/// - no fewer than 1 character
/// - no more than 25 characters
/// - no characters other than:
/// - "roman" alphabet letters (A-Z and a-z)
/// - western digits (0-9)
/// - "safe" punctuation: ! ( ) - . _ SPACE
/// - at least one non-punctuation character
/// Note that we deliberately exclude characters which may cause
/// security problems for websites and databases if escaping is
/// not performed correctly, such as < > " and '.
/// Apologies for the lack of non-English language support.
function validateNameInternal(string _name) constant internal
returns (bool allowed) {
bytes memory nameBytes = bytes(_name);
uint lengthBytes = nameBytes.length;
if (lengthBytes < minimumNameLength ||
lengthBytes > maximumNameLength) {
return false;
}
bool foundNonPunctuation = false;
for (uint i = 0; i < lengthBytes; i++) {
byte b = nameBytes[i];
if (
(b >= 48 && b <= 57) || // 0 - 9
(b >= 65 && b <= 90) || // A - Z
(b >= 97 && b <= 122) // a - z
) {
foundNonPunctuation = true;
continue;
}
if (
b == 32 || // space
b == 33 || // !
b == 40 || // (
b == 41 || // )
b == 45 || // -
b == 46 || // .
b == 95 // _
) {
continue;
}
return false;
}
return foundNonPunctuation;
}
/// if you want to donate, please use the donate function
function() { require(false); }
// PLAYER FUNCTIONS
//
// FOR PLAYERS
/// Name must only include upper and lowercase English letters,
/// numbers, and certain characters: ! ( ) - . _ SPACE
/// Function will return false if the name is not valid
/// or if it's too similar to a name that's already taken.
function setName(string name) returns (bool success) {
require (validateNameInternal(name));
uint fuzzyHash = computeNameFuzzyHash(name);
uint oldFuzzyHash;
string storage oldName = playerNames[msg.sender];
bool oldNameEmpty = bytes(oldName).length == 0;
if (nameTaken[fuzzyHash]) {
require(!oldNameEmpty);
oldFuzzyHash = computeNameFuzzyHash(oldName);
require(fuzzyHash == oldFuzzyHash);
}
else {
if (!oldNameEmpty) {
oldFuzzyHash = computeNameFuzzyHash(oldName);
nameTaken[oldFuzzyHash] = false;
}
nameTaken[fuzzyHash] = true;
}
playerNames[msg.sender] = name;
NewName(msg.sender, name);
return true;
}
//{
/// Create a game that may be joined only by the address provided.
/// If no address is provided, the game is open to anyone.
/// Your bet is equal to the value sent together
/// with this transaction. If the game is a draw,
/// your bet will be available for withdrawal.
/// If you win, both bets minus the fee will be send to you.
/// The first argument should be the number
/// of your move (rock: 1, paper: 2, scissors: 3)
/// encrypted with keccak256(uint move, string secret) and
/// save the secret so you can reveal your move
/// after your game is joined.
/// It's very easy to mess up the padding and stuff,
/// so you should just use the website.
//}
function createGame(bytes32 move, uint val, address player2)
payable notPaused notExpired returns (uint gameId) {
deposit();
require(balances[msg.sender] >= val);
require(!secretTaken[move]);
secretTaken[move] = true;
balances[msg.sender] -= val;
gameId = gameIdCounter;
games.push(Game(msg.sender, player2, val, move, 0, 0, 0, State.Created, Result(0)));
GameCreated(msg.sender, player2, gameId, val, move);
gameIdCounter++;
}
function abortGame(uint gameId) notPaused returns (bool success) {
Game storage thisGame = games[gameId];
require(thisGame.player1 == msg.sender);
require(thisGame.state == State.Created);
thisGame.state = State.Ended;
GameEnded(thisGame.player1, thisGame.player2, gameId, thisGame.value, Result(0));
msg.sender.transfer(thisGame.value);
return true;
}
function joinGame(uint gameId, uint8 move) payable notPaused returns (bool success) {
Game storage thisGame = games[gameId];
require(thisGame.state == State.Created);
require(move > 0 && move <= 3);
if (thisGame.player2 == 0x0) {
thisGame.player2 = msg.sender;
}
else {
require(thisGame.player2 == msg.sender);
}
require(thisGame.value == msg.value);
thisGame.gameStart = now;
thisGame.state = State.Joined;
thisGame.move2 = move;
GameJoined(thisGame.player1, thisGame.player2, gameId, thisGame.value, thisGame.move2, thisGame.gameStart);
return true;
}
function revealMove(uint gameId, uint8 move, string secret) notPaused returns (Result result) {
Game storage thisGame = games[gameId];
require(thisGame.state == State.Joined);
require(thisGame.player1 == msg.sender);
require(thisGame.gameStart + revealTime >= now); // It's not too late to reveal
require(thisGame.hiddenMove1 == keccak256(uint(move), secret));
thisGame.move1 = move;
if (move > 0 && move <= 3) {
result = Result(((3 + move - thisGame.move2) % 3) + 1); // It works trust me (it's 'cause of math)
}
else { // Player 1 submitted invalid move
result = Result.Loss;
}
thisGame.state = State.Ended;
address winner;
if (result == Result.Draw) {
balances[thisGame.player1] += thisGame.value;
balances[thisGame.player2] += thisGame.value;
}
else {
if (result == Result.Win) {
winner = thisGame.player1;
totalLost[thisGame.player2] += thisGame.value;
}
else {
winner = thisGame.player2;
totalLost[thisGame.player1] += thisGame.value;
}
uint fee = (thisGame.value) / feeDivisor; // 0.5% fee taken once for each owner
balances[owner1] += fee;
balances[owner2] += fee;
totalWon[winner] += thisGame.value - fee*2;
// No re-entrancy attack is possible because
// the state has already been set to State.Ended
winner.transfer((thisGame.value*2) - fee*2);
}
thisGame.result = result;
GameEnded(thisGame.player1, thisGame.player2, gameId, thisGame.value, result);
}
/// Use this when you know you've lost as player 1 and
/// you don't want to bother with revealing your move.
function forfeitGame(uint gameId) notPaused returns (bool success) {
Game storage thisGame = games[gameId];
require(thisGame.state == State.Joined);
require(thisGame.player1 == msg.sender);
uint fee = (thisGame.value) / feeDivisor; // 0.5% fee taken once for each owner
balances[owner1] += fee;
balances[owner2] += fee;
totalLost[thisGame.player1] += thisGame.value;
totalWon[thisGame.player2] += thisGame.value - fee*2;
thisGame.state = State.Ended;
thisGame.result = Result.Forfeit; // Loss for player 1
GameEnded(thisGame.player1, thisGame.player2, gameId, thisGame.value, thisGame.result);
thisGame.player2.transfer((thisGame.value*2) - fee*2);
return true;
}
function claimGame(uint gameId) notPaused returns (bool success) {
Game storage thisGame = games[gameId];
require(thisGame.state == State.Joined);
require(thisGame.player2 == msg.sender);
require(thisGame.gameStart + revealTime < now); // Player 1 has failed to reveal in time
uint fee = (thisGame.value) / feeDivisor; // 0.5% fee taken once for each owner
balances[owner1] += fee;
balances[owner2] += fee;
totalLost[thisGame.player1] += thisGame.value;
totalWon[thisGame.player2] += thisGame.value - fee*2;
thisGame.state = State.Ended;
thisGame.result = Result.Forfeit; // Loss for player 1
GameEnded(thisGame.player1, thisGame.player2, gameId, thisGame.value, thisGame.result);
thisGame.player2.transfer((thisGame.value*2) - fee*2);
return true;
}
// FUNDING FUNCTIONS
//
// FOR FUNDING
function donate() payable returns (bool success) {
require(msg.value != 0);
balances[owner1] += msg.value/2;
balances[owner2] += msg.value - msg.value/2;
Donate(msg.sender, msg.value);
return true;
}
function deposit() payable returns (bool success) {
require(msg.value != 0);
balances[msg.sender] += msg.value;
Deposit(msg.sender, msg.value);
return true;
}
function withdraw() returns (bool success) {
uint amount = balances[msg.sender];
if (amount == 0) return false;
balances[msg.sender] = 0;
msg.sender.transfer(amount);
Withdraw(msg.sender, amount);
return true;
}
// ADMIN FUNCTIONS
//
// FOR ADMINISTRATING
// Pause all gameplay
function pause(bool pause) onlyOwner {
paused = pause;
}
// Prevent new games from being created
// To be used when switching to a new contract
function expire(bool expire) onlyOwner {
expired = expire;
}
function setOwner1(address newOwner) {
require(msg.sender == owner1);
owner1 = newOwner;
}
function setOwner2(address newOwner) {
require(msg.sender == owner2);
owner2 = newOwner;
}
} | donate | function donate() payable returns (bool success) {
require(msg.value != 0);
balances[owner1] += msg.value/2;
balances[owner2] += msg.value - msg.value/2;
Donate(msg.sender, msg.value);
return true;
}
| // FUNDING FUNCTIONS
//
// FOR FUNDING | LineComment | v0.4.11+commit.68ef5810 | bzzr://6efdff4f2b8d471875b9932830f1cb8516e742dab2186d5ff8f6b7412b67b75e | {
"func_code_index": [
12833,
13089
]
} | 2,549 |
|||
RPS | RPS.sol | 0x5df4bea3540899a33c76c4d25108f4fe2ca89044 | Solidity | RPS | contract RPS {
enum State { Unrealized, Created, Joined, Ended }
enum Result { Unfinished, Draw, Win, Loss, Forfeit } // From the perspective of player 1
struct Game {
address player1;
address player2;
uint value;
bytes32 hiddenMove1;
uint8 move1; // 0 = not set, 1 = Rock, 2 = Paper, 3 = Scissors
uint8 move2;
uint gameStart;
State state;
Result result;
}
address public owner1;
address public owner2;
uint8 constant feeDivisor = 100;
uint constant revealTime = 7 days; // TODO: dynamic reveal times?
bool paused;
bool expired;
uint gameIdCounter;
uint constant minimumNameLength = 1;
uint constant maximumNameLength = 25;
event NewName(address indexed player, string name);
event Donate(address indexed player, uint amount);
event Deposit(address indexed player, uint amount);
event Withdraw(address indexed player, uint amount);
event GameCreated(address indexed player1, address indexed player2, uint indexed gameId, uint value, bytes32 hiddenMove1);
event GameJoined(address indexed player1, address indexed player2, uint indexed gameId, uint value, uint8 move2, uint gameStart);
event GameEnded(address indexed player1, address indexed player2, uint indexed gameId, uint value, Result result);
mapping(address => uint) public balances;
mapping(address => uint) public totalWon;
mapping(address => uint) public totalLost;
Game [] public games;
mapping(address => string) public playerNames;
mapping(uint => bool) public nameTaken;
mapping(bytes32 => bool) public secretTaken;
modifier onlyOwner { require(msg.sender == owner1 || msg.sender == owner2); _; }
modifier notPaused { require(!paused); _; }
modifier notExpired { require(!expired); _; }
function RPS(address otherOwner) {
owner1 = msg.sender;
owner2 = otherOwner;
paused = true;
}
// UTILIY FUNCTIONS
//
// FOR DOING BORING REPETITIVE TASKS
function getGames() constant internal returns (Game []) {
return games;
}
function totalProfit(address player) constant returns (int) {
if (totalLost[player] > totalWon[player]) {
return -int(totalLost[player] - totalWon[player]);
}
else {
return int(totalWon[player] - totalLost[player]);
}
}
// Fuzzy hash and name validation taken from King of the Ether Throne
// https://github.com/kieranelby/KingOfTheEtherThrone/blob/v1.0/contracts/KingOfTheEtherThrone.sol
function computeNameFuzzyHash(string _name) constant internal
returns (uint fuzzyHash) {
bytes memory nameBytes = bytes(_name);
uint h = 0;
uint len = nameBytes.length;
if (len > maximumNameLength) {
len = maximumNameLength;
}
for (uint i = 0; i < len; i++) {
uint mul = 128;
byte b = nameBytes[i];
uint ub = uint(b);
if (b >= 48 && b <= 57) {
// 0-9
h = h * mul + ub;
} else if (b >= 65 && b <= 90) {
// A-Z
h = h * mul + ub;
} else if (b >= 97 && b <= 122) {
// fold a-z to A-Z
uint upper = ub - 32;
h = h * mul + upper;
} else {
// ignore others
}
}
return h;
}
/// @return True if-and-only-if `_name_` meets the criteria
/// below, or false otherwise:
/// - no fewer than 1 character
/// - no more than 25 characters
/// - no characters other than:
/// - "roman" alphabet letters (A-Z and a-z)
/// - western digits (0-9)
/// - "safe" punctuation: ! ( ) - . _ SPACE
/// - at least one non-punctuation character
/// Note that we deliberately exclude characters which may cause
/// security problems for websites and databases if escaping is
/// not performed correctly, such as < > " and '.
/// Apologies for the lack of non-English language support.
function validateNameInternal(string _name) constant internal
returns (bool allowed) {
bytes memory nameBytes = bytes(_name);
uint lengthBytes = nameBytes.length;
if (lengthBytes < minimumNameLength ||
lengthBytes > maximumNameLength) {
return false;
}
bool foundNonPunctuation = false;
for (uint i = 0; i < lengthBytes; i++) {
byte b = nameBytes[i];
if (
(b >= 48 && b <= 57) || // 0 - 9
(b >= 65 && b <= 90) || // A - Z
(b >= 97 && b <= 122) // a - z
) {
foundNonPunctuation = true;
continue;
}
if (
b == 32 || // space
b == 33 || // !
b == 40 || // (
b == 41 || // )
b == 45 || // -
b == 46 || // .
b == 95 // _
) {
continue;
}
return false;
}
return foundNonPunctuation;
}
/// if you want to donate, please use the donate function
function() { require(false); }
// PLAYER FUNCTIONS
//
// FOR PLAYERS
/// Name must only include upper and lowercase English letters,
/// numbers, and certain characters: ! ( ) - . _ SPACE
/// Function will return false if the name is not valid
/// or if it's too similar to a name that's already taken.
function setName(string name) returns (bool success) {
require (validateNameInternal(name));
uint fuzzyHash = computeNameFuzzyHash(name);
uint oldFuzzyHash;
string storage oldName = playerNames[msg.sender];
bool oldNameEmpty = bytes(oldName).length == 0;
if (nameTaken[fuzzyHash]) {
require(!oldNameEmpty);
oldFuzzyHash = computeNameFuzzyHash(oldName);
require(fuzzyHash == oldFuzzyHash);
}
else {
if (!oldNameEmpty) {
oldFuzzyHash = computeNameFuzzyHash(oldName);
nameTaken[oldFuzzyHash] = false;
}
nameTaken[fuzzyHash] = true;
}
playerNames[msg.sender] = name;
NewName(msg.sender, name);
return true;
}
//{
/// Create a game that may be joined only by the address provided.
/// If no address is provided, the game is open to anyone.
/// Your bet is equal to the value sent together
/// with this transaction. If the game is a draw,
/// your bet will be available for withdrawal.
/// If you win, both bets minus the fee will be send to you.
/// The first argument should be the number
/// of your move (rock: 1, paper: 2, scissors: 3)
/// encrypted with keccak256(uint move, string secret) and
/// save the secret so you can reveal your move
/// after your game is joined.
/// It's very easy to mess up the padding and stuff,
/// so you should just use the website.
//}
function createGame(bytes32 move, uint val, address player2)
payable notPaused notExpired returns (uint gameId) {
deposit();
require(balances[msg.sender] >= val);
require(!secretTaken[move]);
secretTaken[move] = true;
balances[msg.sender] -= val;
gameId = gameIdCounter;
games.push(Game(msg.sender, player2, val, move, 0, 0, 0, State.Created, Result(0)));
GameCreated(msg.sender, player2, gameId, val, move);
gameIdCounter++;
}
function abortGame(uint gameId) notPaused returns (bool success) {
Game storage thisGame = games[gameId];
require(thisGame.player1 == msg.sender);
require(thisGame.state == State.Created);
thisGame.state = State.Ended;
GameEnded(thisGame.player1, thisGame.player2, gameId, thisGame.value, Result(0));
msg.sender.transfer(thisGame.value);
return true;
}
function joinGame(uint gameId, uint8 move) payable notPaused returns (bool success) {
Game storage thisGame = games[gameId];
require(thisGame.state == State.Created);
require(move > 0 && move <= 3);
if (thisGame.player2 == 0x0) {
thisGame.player2 = msg.sender;
}
else {
require(thisGame.player2 == msg.sender);
}
require(thisGame.value == msg.value);
thisGame.gameStart = now;
thisGame.state = State.Joined;
thisGame.move2 = move;
GameJoined(thisGame.player1, thisGame.player2, gameId, thisGame.value, thisGame.move2, thisGame.gameStart);
return true;
}
function revealMove(uint gameId, uint8 move, string secret) notPaused returns (Result result) {
Game storage thisGame = games[gameId];
require(thisGame.state == State.Joined);
require(thisGame.player1 == msg.sender);
require(thisGame.gameStart + revealTime >= now); // It's not too late to reveal
require(thisGame.hiddenMove1 == keccak256(uint(move), secret));
thisGame.move1 = move;
if (move > 0 && move <= 3) {
result = Result(((3 + move - thisGame.move2) % 3) + 1); // It works trust me (it's 'cause of math)
}
else { // Player 1 submitted invalid move
result = Result.Loss;
}
thisGame.state = State.Ended;
address winner;
if (result == Result.Draw) {
balances[thisGame.player1] += thisGame.value;
balances[thisGame.player2] += thisGame.value;
}
else {
if (result == Result.Win) {
winner = thisGame.player1;
totalLost[thisGame.player2] += thisGame.value;
}
else {
winner = thisGame.player2;
totalLost[thisGame.player1] += thisGame.value;
}
uint fee = (thisGame.value) / feeDivisor; // 0.5% fee taken once for each owner
balances[owner1] += fee;
balances[owner2] += fee;
totalWon[winner] += thisGame.value - fee*2;
// No re-entrancy attack is possible because
// the state has already been set to State.Ended
winner.transfer((thisGame.value*2) - fee*2);
}
thisGame.result = result;
GameEnded(thisGame.player1, thisGame.player2, gameId, thisGame.value, result);
}
/// Use this when you know you've lost as player 1 and
/// you don't want to bother with revealing your move.
function forfeitGame(uint gameId) notPaused returns (bool success) {
Game storage thisGame = games[gameId];
require(thisGame.state == State.Joined);
require(thisGame.player1 == msg.sender);
uint fee = (thisGame.value) / feeDivisor; // 0.5% fee taken once for each owner
balances[owner1] += fee;
balances[owner2] += fee;
totalLost[thisGame.player1] += thisGame.value;
totalWon[thisGame.player2] += thisGame.value - fee*2;
thisGame.state = State.Ended;
thisGame.result = Result.Forfeit; // Loss for player 1
GameEnded(thisGame.player1, thisGame.player2, gameId, thisGame.value, thisGame.result);
thisGame.player2.transfer((thisGame.value*2) - fee*2);
return true;
}
function claimGame(uint gameId) notPaused returns (bool success) {
Game storage thisGame = games[gameId];
require(thisGame.state == State.Joined);
require(thisGame.player2 == msg.sender);
require(thisGame.gameStart + revealTime < now); // Player 1 has failed to reveal in time
uint fee = (thisGame.value) / feeDivisor; // 0.5% fee taken once for each owner
balances[owner1] += fee;
balances[owner2] += fee;
totalLost[thisGame.player1] += thisGame.value;
totalWon[thisGame.player2] += thisGame.value - fee*2;
thisGame.state = State.Ended;
thisGame.result = Result.Forfeit; // Loss for player 1
GameEnded(thisGame.player1, thisGame.player2, gameId, thisGame.value, thisGame.result);
thisGame.player2.transfer((thisGame.value*2) - fee*2);
return true;
}
// FUNDING FUNCTIONS
//
// FOR FUNDING
function donate() payable returns (bool success) {
require(msg.value != 0);
balances[owner1] += msg.value/2;
balances[owner2] += msg.value - msg.value/2;
Donate(msg.sender, msg.value);
return true;
}
function deposit() payable returns (bool success) {
require(msg.value != 0);
balances[msg.sender] += msg.value;
Deposit(msg.sender, msg.value);
return true;
}
function withdraw() returns (bool success) {
uint amount = balances[msg.sender];
if (amount == 0) return false;
balances[msg.sender] = 0;
msg.sender.transfer(amount);
Withdraw(msg.sender, amount);
return true;
}
// ADMIN FUNCTIONS
//
// FOR ADMINISTRATING
// Pause all gameplay
function pause(bool pause) onlyOwner {
paused = pause;
}
// Prevent new games from being created
// To be used when switching to a new contract
function expire(bool expire) onlyOwner {
expired = expire;
}
function setOwner1(address newOwner) {
require(msg.sender == owner1);
owner1 = newOwner;
}
function setOwner2(address newOwner) {
require(msg.sender == owner2);
owner2 = newOwner;
}
} | pause | function pause(bool pause) onlyOwner {
paused = pause;
}
| // ADMIN FUNCTIONS
//
// FOR ADMINISTRATING
// Pause all gameplay | LineComment | v0.4.11+commit.68ef5810 | bzzr://6efdff4f2b8d471875b9932830f1cb8516e742dab2186d5ff8f6b7412b67b75e | {
"func_code_index": [
13673,
13748
]
} | 2,550 |
|||
RPS | RPS.sol | 0x5df4bea3540899a33c76c4d25108f4fe2ca89044 | Solidity | RPS | contract RPS {
enum State { Unrealized, Created, Joined, Ended }
enum Result { Unfinished, Draw, Win, Loss, Forfeit } // From the perspective of player 1
struct Game {
address player1;
address player2;
uint value;
bytes32 hiddenMove1;
uint8 move1; // 0 = not set, 1 = Rock, 2 = Paper, 3 = Scissors
uint8 move2;
uint gameStart;
State state;
Result result;
}
address public owner1;
address public owner2;
uint8 constant feeDivisor = 100;
uint constant revealTime = 7 days; // TODO: dynamic reveal times?
bool paused;
bool expired;
uint gameIdCounter;
uint constant minimumNameLength = 1;
uint constant maximumNameLength = 25;
event NewName(address indexed player, string name);
event Donate(address indexed player, uint amount);
event Deposit(address indexed player, uint amount);
event Withdraw(address indexed player, uint amount);
event GameCreated(address indexed player1, address indexed player2, uint indexed gameId, uint value, bytes32 hiddenMove1);
event GameJoined(address indexed player1, address indexed player2, uint indexed gameId, uint value, uint8 move2, uint gameStart);
event GameEnded(address indexed player1, address indexed player2, uint indexed gameId, uint value, Result result);
mapping(address => uint) public balances;
mapping(address => uint) public totalWon;
mapping(address => uint) public totalLost;
Game [] public games;
mapping(address => string) public playerNames;
mapping(uint => bool) public nameTaken;
mapping(bytes32 => bool) public secretTaken;
modifier onlyOwner { require(msg.sender == owner1 || msg.sender == owner2); _; }
modifier notPaused { require(!paused); _; }
modifier notExpired { require(!expired); _; }
function RPS(address otherOwner) {
owner1 = msg.sender;
owner2 = otherOwner;
paused = true;
}
// UTILIY FUNCTIONS
//
// FOR DOING BORING REPETITIVE TASKS
function getGames() constant internal returns (Game []) {
return games;
}
function totalProfit(address player) constant returns (int) {
if (totalLost[player] > totalWon[player]) {
return -int(totalLost[player] - totalWon[player]);
}
else {
return int(totalWon[player] - totalLost[player]);
}
}
// Fuzzy hash and name validation taken from King of the Ether Throne
// https://github.com/kieranelby/KingOfTheEtherThrone/blob/v1.0/contracts/KingOfTheEtherThrone.sol
function computeNameFuzzyHash(string _name) constant internal
returns (uint fuzzyHash) {
bytes memory nameBytes = bytes(_name);
uint h = 0;
uint len = nameBytes.length;
if (len > maximumNameLength) {
len = maximumNameLength;
}
for (uint i = 0; i < len; i++) {
uint mul = 128;
byte b = nameBytes[i];
uint ub = uint(b);
if (b >= 48 && b <= 57) {
// 0-9
h = h * mul + ub;
} else if (b >= 65 && b <= 90) {
// A-Z
h = h * mul + ub;
} else if (b >= 97 && b <= 122) {
// fold a-z to A-Z
uint upper = ub - 32;
h = h * mul + upper;
} else {
// ignore others
}
}
return h;
}
/// @return True if-and-only-if `_name_` meets the criteria
/// below, or false otherwise:
/// - no fewer than 1 character
/// - no more than 25 characters
/// - no characters other than:
/// - "roman" alphabet letters (A-Z and a-z)
/// - western digits (0-9)
/// - "safe" punctuation: ! ( ) - . _ SPACE
/// - at least one non-punctuation character
/// Note that we deliberately exclude characters which may cause
/// security problems for websites and databases if escaping is
/// not performed correctly, such as < > " and '.
/// Apologies for the lack of non-English language support.
function validateNameInternal(string _name) constant internal
returns (bool allowed) {
bytes memory nameBytes = bytes(_name);
uint lengthBytes = nameBytes.length;
if (lengthBytes < minimumNameLength ||
lengthBytes > maximumNameLength) {
return false;
}
bool foundNonPunctuation = false;
for (uint i = 0; i < lengthBytes; i++) {
byte b = nameBytes[i];
if (
(b >= 48 && b <= 57) || // 0 - 9
(b >= 65 && b <= 90) || // A - Z
(b >= 97 && b <= 122) // a - z
) {
foundNonPunctuation = true;
continue;
}
if (
b == 32 || // space
b == 33 || // !
b == 40 || // (
b == 41 || // )
b == 45 || // -
b == 46 || // .
b == 95 // _
) {
continue;
}
return false;
}
return foundNonPunctuation;
}
/// if you want to donate, please use the donate function
function() { require(false); }
// PLAYER FUNCTIONS
//
// FOR PLAYERS
/// Name must only include upper and lowercase English letters,
/// numbers, and certain characters: ! ( ) - . _ SPACE
/// Function will return false if the name is not valid
/// or if it's too similar to a name that's already taken.
function setName(string name) returns (bool success) {
require (validateNameInternal(name));
uint fuzzyHash = computeNameFuzzyHash(name);
uint oldFuzzyHash;
string storage oldName = playerNames[msg.sender];
bool oldNameEmpty = bytes(oldName).length == 0;
if (nameTaken[fuzzyHash]) {
require(!oldNameEmpty);
oldFuzzyHash = computeNameFuzzyHash(oldName);
require(fuzzyHash == oldFuzzyHash);
}
else {
if (!oldNameEmpty) {
oldFuzzyHash = computeNameFuzzyHash(oldName);
nameTaken[oldFuzzyHash] = false;
}
nameTaken[fuzzyHash] = true;
}
playerNames[msg.sender] = name;
NewName(msg.sender, name);
return true;
}
//{
/// Create a game that may be joined only by the address provided.
/// If no address is provided, the game is open to anyone.
/// Your bet is equal to the value sent together
/// with this transaction. If the game is a draw,
/// your bet will be available for withdrawal.
/// If you win, both bets minus the fee will be send to you.
/// The first argument should be the number
/// of your move (rock: 1, paper: 2, scissors: 3)
/// encrypted with keccak256(uint move, string secret) and
/// save the secret so you can reveal your move
/// after your game is joined.
/// It's very easy to mess up the padding and stuff,
/// so you should just use the website.
//}
function createGame(bytes32 move, uint val, address player2)
payable notPaused notExpired returns (uint gameId) {
deposit();
require(balances[msg.sender] >= val);
require(!secretTaken[move]);
secretTaken[move] = true;
balances[msg.sender] -= val;
gameId = gameIdCounter;
games.push(Game(msg.sender, player2, val, move, 0, 0, 0, State.Created, Result(0)));
GameCreated(msg.sender, player2, gameId, val, move);
gameIdCounter++;
}
function abortGame(uint gameId) notPaused returns (bool success) {
Game storage thisGame = games[gameId];
require(thisGame.player1 == msg.sender);
require(thisGame.state == State.Created);
thisGame.state = State.Ended;
GameEnded(thisGame.player1, thisGame.player2, gameId, thisGame.value, Result(0));
msg.sender.transfer(thisGame.value);
return true;
}
function joinGame(uint gameId, uint8 move) payable notPaused returns (bool success) {
Game storage thisGame = games[gameId];
require(thisGame.state == State.Created);
require(move > 0 && move <= 3);
if (thisGame.player2 == 0x0) {
thisGame.player2 = msg.sender;
}
else {
require(thisGame.player2 == msg.sender);
}
require(thisGame.value == msg.value);
thisGame.gameStart = now;
thisGame.state = State.Joined;
thisGame.move2 = move;
GameJoined(thisGame.player1, thisGame.player2, gameId, thisGame.value, thisGame.move2, thisGame.gameStart);
return true;
}
function revealMove(uint gameId, uint8 move, string secret) notPaused returns (Result result) {
Game storage thisGame = games[gameId];
require(thisGame.state == State.Joined);
require(thisGame.player1 == msg.sender);
require(thisGame.gameStart + revealTime >= now); // It's not too late to reveal
require(thisGame.hiddenMove1 == keccak256(uint(move), secret));
thisGame.move1 = move;
if (move > 0 && move <= 3) {
result = Result(((3 + move - thisGame.move2) % 3) + 1); // It works trust me (it's 'cause of math)
}
else { // Player 1 submitted invalid move
result = Result.Loss;
}
thisGame.state = State.Ended;
address winner;
if (result == Result.Draw) {
balances[thisGame.player1] += thisGame.value;
balances[thisGame.player2] += thisGame.value;
}
else {
if (result == Result.Win) {
winner = thisGame.player1;
totalLost[thisGame.player2] += thisGame.value;
}
else {
winner = thisGame.player2;
totalLost[thisGame.player1] += thisGame.value;
}
uint fee = (thisGame.value) / feeDivisor; // 0.5% fee taken once for each owner
balances[owner1] += fee;
balances[owner2] += fee;
totalWon[winner] += thisGame.value - fee*2;
// No re-entrancy attack is possible because
// the state has already been set to State.Ended
winner.transfer((thisGame.value*2) - fee*2);
}
thisGame.result = result;
GameEnded(thisGame.player1, thisGame.player2, gameId, thisGame.value, result);
}
/// Use this when you know you've lost as player 1 and
/// you don't want to bother with revealing your move.
function forfeitGame(uint gameId) notPaused returns (bool success) {
Game storage thisGame = games[gameId];
require(thisGame.state == State.Joined);
require(thisGame.player1 == msg.sender);
uint fee = (thisGame.value) / feeDivisor; // 0.5% fee taken once for each owner
balances[owner1] += fee;
balances[owner2] += fee;
totalLost[thisGame.player1] += thisGame.value;
totalWon[thisGame.player2] += thisGame.value - fee*2;
thisGame.state = State.Ended;
thisGame.result = Result.Forfeit; // Loss for player 1
GameEnded(thisGame.player1, thisGame.player2, gameId, thisGame.value, thisGame.result);
thisGame.player2.transfer((thisGame.value*2) - fee*2);
return true;
}
function claimGame(uint gameId) notPaused returns (bool success) {
Game storage thisGame = games[gameId];
require(thisGame.state == State.Joined);
require(thisGame.player2 == msg.sender);
require(thisGame.gameStart + revealTime < now); // Player 1 has failed to reveal in time
uint fee = (thisGame.value) / feeDivisor; // 0.5% fee taken once for each owner
balances[owner1] += fee;
balances[owner2] += fee;
totalLost[thisGame.player1] += thisGame.value;
totalWon[thisGame.player2] += thisGame.value - fee*2;
thisGame.state = State.Ended;
thisGame.result = Result.Forfeit; // Loss for player 1
GameEnded(thisGame.player1, thisGame.player2, gameId, thisGame.value, thisGame.result);
thisGame.player2.transfer((thisGame.value*2) - fee*2);
return true;
}
// FUNDING FUNCTIONS
//
// FOR FUNDING
function donate() payable returns (bool success) {
require(msg.value != 0);
balances[owner1] += msg.value/2;
balances[owner2] += msg.value - msg.value/2;
Donate(msg.sender, msg.value);
return true;
}
function deposit() payable returns (bool success) {
require(msg.value != 0);
balances[msg.sender] += msg.value;
Deposit(msg.sender, msg.value);
return true;
}
function withdraw() returns (bool success) {
uint amount = balances[msg.sender];
if (amount == 0) return false;
balances[msg.sender] = 0;
msg.sender.transfer(amount);
Withdraw(msg.sender, amount);
return true;
}
// ADMIN FUNCTIONS
//
// FOR ADMINISTRATING
// Pause all gameplay
function pause(bool pause) onlyOwner {
paused = pause;
}
// Prevent new games from being created
// To be used when switching to a new contract
function expire(bool expire) onlyOwner {
expired = expire;
}
function setOwner1(address newOwner) {
require(msg.sender == owner1);
owner1 = newOwner;
}
function setOwner2(address newOwner) {
require(msg.sender == owner2);
owner2 = newOwner;
}
} | expire | function expire(bool expire) onlyOwner {
expired = expire;
}
| // Prevent new games from being created
// To be used when switching to a new contract | LineComment | v0.4.11+commit.68ef5810 | bzzr://6efdff4f2b8d471875b9932830f1cb8516e742dab2186d5ff8f6b7412b67b75e | {
"func_code_index": [
13852,
13931
]
} | 2,551 |
|||
MemePetToken | MemePetToken.sol | 0x3c62660fbae5099180ffcc2d17f25f066bc64825 | Solidity | Token | contract Token {
/// @return total amount of tokens
function totalSupply() constant returns (uint256 supply) {}
/// @param _owner The address from which the balance will be retrieved
/// @return The balance
function balanceOf(address _owner) constant returns (uint256 balance) {}
/// @notice send `_value` token to `_to` from `msg.sender`
/// @param _to The address of the recipient
/// @param _value The amount of token to be transferred
/// @return Whether the transfer was successful or not
function transfer(address _to, uint256 _value) returns (bool success) {}
/// @notice send `_value` token to `_to` from `_from` on the condition it is approved by `_from`
/// @param _from The address of the sender
/// @param _to The address of the recipient
/// @param _value The amount of token to be transferred
/// @return Whether the transfer was successful or not
function transferFrom(address _from, address _to, uint256 _value) returns (bool success) {}
/// @notice `msg.sender` approves `_addr` to spend `_value` tokens
/// @param _spender The address of the account able to transfer the tokens
/// @param _value The amount of wei to be approved for transfer
/// @return Whether the approval was successful or not
function approve(address _spender, uint256 _value) returns (bool success) {}
/// @param _owner The address of the account owning tokens
/// @param _spender The address of the account able to transfer the tokens
/// @return Amount of remaining tokens allowed to spent
function allowance(address _owner, address _spender) constant returns (uint256 remaining) {}
event Transfer(address indexed _from, address indexed _to, uint256 _value);
event Approval(address indexed _owner, address indexed _spender, uint256 _value);
} | totalSupply | function totalSupply() constant returns (uint256 supply) {}
| /// @return total amount of tokens | NatSpecSingleLine | v0.4.25+commit.59dbf8f1 | None | bzzr://212a26e9e38c0f1a1169d731e712b4868635eb4c791305026edd70e56ba3a82a | {
"func_code_index": [
60,
124
]
} | 2,552 |
||
MemePetToken | MemePetToken.sol | 0x3c62660fbae5099180ffcc2d17f25f066bc64825 | Solidity | Token | contract Token {
/// @return total amount of tokens
function totalSupply() constant returns (uint256 supply) {}
/// @param _owner The address from which the balance will be retrieved
/// @return The balance
function balanceOf(address _owner) constant returns (uint256 balance) {}
/// @notice send `_value` token to `_to` from `msg.sender`
/// @param _to The address of the recipient
/// @param _value The amount of token to be transferred
/// @return Whether the transfer was successful or not
function transfer(address _to, uint256 _value) returns (bool success) {}
/// @notice send `_value` token to `_to` from `_from` on the condition it is approved by `_from`
/// @param _from The address of the sender
/// @param _to The address of the recipient
/// @param _value The amount of token to be transferred
/// @return Whether the transfer was successful or not
function transferFrom(address _from, address _to, uint256 _value) returns (bool success) {}
/// @notice `msg.sender` approves `_addr` to spend `_value` tokens
/// @param _spender The address of the account able to transfer the tokens
/// @param _value The amount of wei to be approved for transfer
/// @return Whether the approval was successful or not
function approve(address _spender, uint256 _value) returns (bool success) {}
/// @param _owner The address of the account owning tokens
/// @param _spender The address of the account able to transfer the tokens
/// @return Amount of remaining tokens allowed to spent
function allowance(address _owner, address _spender) constant returns (uint256 remaining) {}
event Transfer(address indexed _from, address indexed _to, uint256 _value);
event Approval(address indexed _owner, address indexed _spender, uint256 _value);
} | balanceOf | function balanceOf(address _owner) constant returns (uint256 balance) {}
| /// @param _owner The address from which the balance will be retrieved
/// @return The balance | NatSpecSingleLine | v0.4.25+commit.59dbf8f1 | None | bzzr://212a26e9e38c0f1a1169d731e712b4868635eb4c791305026edd70e56ba3a82a | {
"func_code_index": [
232,
309
]
} | 2,553 |
||
MemePetToken | MemePetToken.sol | 0x3c62660fbae5099180ffcc2d17f25f066bc64825 | Solidity | Token | contract Token {
/// @return total amount of tokens
function totalSupply() constant returns (uint256 supply) {}
/// @param _owner The address from which the balance will be retrieved
/// @return The balance
function balanceOf(address _owner) constant returns (uint256 balance) {}
/// @notice send `_value` token to `_to` from `msg.sender`
/// @param _to The address of the recipient
/// @param _value The amount of token to be transferred
/// @return Whether the transfer was successful or not
function transfer(address _to, uint256 _value) returns (bool success) {}
/// @notice send `_value` token to `_to` from `_from` on the condition it is approved by `_from`
/// @param _from The address of the sender
/// @param _to The address of the recipient
/// @param _value The amount of token to be transferred
/// @return Whether the transfer was successful or not
function transferFrom(address _from, address _to, uint256 _value) returns (bool success) {}
/// @notice `msg.sender` approves `_addr` to spend `_value` tokens
/// @param _spender The address of the account able to transfer the tokens
/// @param _value The amount of wei to be approved for transfer
/// @return Whether the approval was successful or not
function approve(address _spender, uint256 _value) returns (bool success) {}
/// @param _owner The address of the account owning tokens
/// @param _spender The address of the account able to transfer the tokens
/// @return Amount of remaining tokens allowed to spent
function allowance(address _owner, address _spender) constant returns (uint256 remaining) {}
event Transfer(address indexed _from, address indexed _to, uint256 _value);
event Approval(address indexed _owner, address indexed _spender, uint256 _value);
} | transfer | function transfer(address _to, uint256 _value) returns (bool success) {}
| /// @notice send `_value` token to `_to` from `msg.sender`
/// @param _to The address of the recipient
/// @param _value The amount of token to be transferred
/// @return Whether the transfer was successful or not | NatSpecSingleLine | v0.4.25+commit.59dbf8f1 | None | bzzr://212a26e9e38c0f1a1169d731e712b4868635eb4c791305026edd70e56ba3a82a | {
"func_code_index": [
546,
623
]
} | 2,554 |
||
MemePetToken | MemePetToken.sol | 0x3c62660fbae5099180ffcc2d17f25f066bc64825 | Solidity | Token | contract Token {
/// @return total amount of tokens
function totalSupply() constant returns (uint256 supply) {}
/// @param _owner The address from which the balance will be retrieved
/// @return The balance
function balanceOf(address _owner) constant returns (uint256 balance) {}
/// @notice send `_value` token to `_to` from `msg.sender`
/// @param _to The address of the recipient
/// @param _value The amount of token to be transferred
/// @return Whether the transfer was successful or not
function transfer(address _to, uint256 _value) returns (bool success) {}
/// @notice send `_value` token to `_to` from `_from` on the condition it is approved by `_from`
/// @param _from The address of the sender
/// @param _to The address of the recipient
/// @param _value The amount of token to be transferred
/// @return Whether the transfer was successful or not
function transferFrom(address _from, address _to, uint256 _value) returns (bool success) {}
/// @notice `msg.sender` approves `_addr` to spend `_value` tokens
/// @param _spender The address of the account able to transfer the tokens
/// @param _value The amount of wei to be approved for transfer
/// @return Whether the approval was successful or not
function approve(address _spender, uint256 _value) returns (bool success) {}
/// @param _owner The address of the account owning tokens
/// @param _spender The address of the account able to transfer the tokens
/// @return Amount of remaining tokens allowed to spent
function allowance(address _owner, address _spender) constant returns (uint256 remaining) {}
event Transfer(address indexed _from, address indexed _to, uint256 _value);
event Approval(address indexed _owner, address indexed _spender, uint256 _value);
} | transferFrom | function transferFrom(address _from, address _to, uint256 _value) returns (bool success) {}
| /// @notice send `_value` token to `_to` from `_from` on the condition it is approved by `_from`
/// @param _from The address of the sender
/// @param _to The address of the recipient
/// @param _value The amount of token to be transferred
/// @return Whether the transfer was successful or not | NatSpecSingleLine | v0.4.25+commit.59dbf8f1 | None | bzzr://212a26e9e38c0f1a1169d731e712b4868635eb4c791305026edd70e56ba3a82a | {
"func_code_index": [
946,
1042
]
} | 2,555 |
||
MemePetToken | MemePetToken.sol | 0x3c62660fbae5099180ffcc2d17f25f066bc64825 | Solidity | Token | contract Token {
/// @return total amount of tokens
function totalSupply() constant returns (uint256 supply) {}
/// @param _owner The address from which the balance will be retrieved
/// @return The balance
function balanceOf(address _owner) constant returns (uint256 balance) {}
/// @notice send `_value` token to `_to` from `msg.sender`
/// @param _to The address of the recipient
/// @param _value The amount of token to be transferred
/// @return Whether the transfer was successful or not
function transfer(address _to, uint256 _value) returns (bool success) {}
/// @notice send `_value` token to `_to` from `_from` on the condition it is approved by `_from`
/// @param _from The address of the sender
/// @param _to The address of the recipient
/// @param _value The amount of token to be transferred
/// @return Whether the transfer was successful or not
function transferFrom(address _from, address _to, uint256 _value) returns (bool success) {}
/// @notice `msg.sender` approves `_addr` to spend `_value` tokens
/// @param _spender The address of the account able to transfer the tokens
/// @param _value The amount of wei to be approved for transfer
/// @return Whether the approval was successful or not
function approve(address _spender, uint256 _value) returns (bool success) {}
/// @param _owner The address of the account owning tokens
/// @param _spender The address of the account able to transfer the tokens
/// @return Amount of remaining tokens allowed to spent
function allowance(address _owner, address _spender) constant returns (uint256 remaining) {}
event Transfer(address indexed _from, address indexed _to, uint256 _value);
event Approval(address indexed _owner, address indexed _spender, uint256 _value);
} | approve | function approve(address _spender, uint256 _value) returns (bool success) {}
| /// @notice `msg.sender` approves `_addr` to spend `_value` tokens
/// @param _spender The address of the account able to transfer the tokens
/// @param _value The amount of wei to be approved for transfer
/// @return Whether the approval was successful or not | NatSpecSingleLine | v0.4.25+commit.59dbf8f1 | None | bzzr://212a26e9e38c0f1a1169d731e712b4868635eb4c791305026edd70e56ba3a82a | {
"func_code_index": [
1326,
1407
]
} | 2,556 |
||
MemePetToken | MemePetToken.sol | 0x3c62660fbae5099180ffcc2d17f25f066bc64825 | Solidity | Token | contract Token {
/// @return total amount of tokens
function totalSupply() constant returns (uint256 supply) {}
/// @param _owner The address from which the balance will be retrieved
/// @return The balance
function balanceOf(address _owner) constant returns (uint256 balance) {}
/// @notice send `_value` token to `_to` from `msg.sender`
/// @param _to The address of the recipient
/// @param _value The amount of token to be transferred
/// @return Whether the transfer was successful or not
function transfer(address _to, uint256 _value) returns (bool success) {}
/// @notice send `_value` token to `_to` from `_from` on the condition it is approved by `_from`
/// @param _from The address of the sender
/// @param _to The address of the recipient
/// @param _value The amount of token to be transferred
/// @return Whether the transfer was successful or not
function transferFrom(address _from, address _to, uint256 _value) returns (bool success) {}
/// @notice `msg.sender` approves `_addr` to spend `_value` tokens
/// @param _spender The address of the account able to transfer the tokens
/// @param _value The amount of wei to be approved for transfer
/// @return Whether the approval was successful or not
function approve(address _spender, uint256 _value) returns (bool success) {}
/// @param _owner The address of the account owning tokens
/// @param _spender The address of the account able to transfer the tokens
/// @return Amount of remaining tokens allowed to spent
function allowance(address _owner, address _spender) constant returns (uint256 remaining) {}
event Transfer(address indexed _from, address indexed _to, uint256 _value);
event Approval(address indexed _owner, address indexed _spender, uint256 _value);
} | allowance | function allowance(address _owner, address _spender) constant returns (uint256 remaining) {}
| /// @param _owner The address of the account owning tokens
/// @param _spender The address of the account able to transfer the tokens
/// @return Amount of remaining tokens allowed to spent | NatSpecSingleLine | v0.4.25+commit.59dbf8f1 | None | bzzr://212a26e9e38c0f1a1169d731e712b4868635eb4c791305026edd70e56ba3a82a | {
"func_code_index": [
1615,
1712
]
} | 2,557 |
||
MemePetToken | MemePetToken.sol | 0x3c62660fbae5099180ffcc2d17f25f066bc64825 | Solidity | MemePetToken | contract MemePetToken is StandardToken {
/* Public variables of the token */
/*
NOTE:
The following variables are OPTIONAL vanities. One does not have to include them.
They allow one to customise the token contract & in no way influences the core functionality.
Some wallets/interfaces might not even bother to look at this information.
*/
string public name;
uint8 public decimals;
string public symbol;
string public version = 'PET1.0';
uint256 public unitsOneEthCanBuy;
uint256 public totalEthInWei;
address public fundsWallet;
function MemePetToken() {
balances[msg.sender] = 100000000000000000000000000000;
totalSupply = 100000000000000000000000000000;
name = "MemePet Token";
decimals = 18;
symbol = "PET";
unitsOneEthCanBuy = 0; //7% bonus= OneEth//
fundsWallet = msg.sender;
}
function() payable{
totalEthInWei = totalEthInWei + msg.value;
uint256 amount = msg.value * unitsOneEthCanBuy;
require(balances[fundsWallet] >= amount);
balances[fundsWallet] = balances[fundsWallet] - amount;
balances[msg.sender] = balances[msg.sender] + amount;
Transfer(fundsWallet, msg.sender, amount);
fundsWallet.transfer(msg.value);
}
/* Approves and then calls the receiving contract */
function approveAndCall(address _spender, uint256 _value, bytes _extraData) returns (bool success) {
allowed[msg.sender][_spender] = _value;
Approval(msg.sender, _spender, _value);
if(!_spender.call(bytes4(bytes32(sha3("receiveApproval(address,uint256,address,bytes)"))), msg.sender, _value, this, _extraData)) { throw; }
return true;
}
} | approveAndCall | function approveAndCall(address _spender, uint256 _value, bytes _extraData) returns (bool success) {
allowed[msg.sender][_spender] = _value;
Approval(msg.sender, _spender, _value);
if(!_spender.call(bytes4(bytes32(sha3("receiveApproval(address,uint256,address,bytes)"))), msg.sender, _value, this, _extraData)) { throw; }
return true;
}
| /* Approves and then calls the receiving contract */ | Comment | v0.4.25+commit.59dbf8f1 | None | bzzr://212a26e9e38c0f1a1169d731e712b4868635eb4c791305026edd70e56ba3a82a | {
"func_code_index": [
1711,
2104
]
} | 2,558 |
||
WalkingApe | contracts/ERC721Enumerable.sol | 0xb088f8926ae002b7f337b6a93ddc2209882ef378 | Solidity | ERC721Enumerable | abstract contract ERC721Enumerable is ERC721, IERC721Enumerable {
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override(IERC165, ERC721) returns (bool) {
return interfaceId == type(IERC721Enumerable).interfaceId || super.supportsInterface(interfaceId);
}
/**
* @dev See {IERC721Enumerable-totalSupply}.
*/
function totalSupply() public view virtual override returns (uint256) {
return _owners.length;
}
/**
* @dev See {IERC721Enumerable-tokenByIndex}.
*/
function tokenByIndex(uint256 index) public view virtual override returns (uint256) {
require(index < _owners.length, "ERC721Enumerable: global index out of bounds");
return index;
}
/**
* @dev See {IERC721Enumerable-tokenOfOwnerByIndex}.
*/
function tokenOfOwnerByIndex(address owner, uint256 index) public view virtual override returns (uint256 tokenId) {
require(index < balanceOf(owner), "ERC721Enumerable: owner index out of bounds");
uint count;
for(uint i; i < _owners.length; i++){
if(owner == _owners[i]){
if(count == index) return i;
else count++;
}
}
revert("ERC721Enumerable: owner index out of bounds");
}
} | /**
* @dev This implements an optional extension of {ERC721} defined in the EIP that adds
* enumerability of all the token ids in the contract as well as all token ids owned by each
* account but rips out the core of the gas-wasting processing that comes from OpenZeppelin.
*/ | NatSpecMultiLine | supportsInterface | function supportsInterface(bytes4 interfaceId) public view virtual override(IERC165, ERC721) returns (bool) {
return interfaceId == type(IERC721Enumerable).interfaceId || super.supportsInterface(interfaceId);
}
| /**
* @dev See {IERC165-supportsInterface}.
*/ | NatSpecMultiLine | v0.8.7+commit.e28d00a7 | {
"func_code_index": [
131,
360
]
} | 2,559 |
||
WalkingApe | contracts/ERC721Enumerable.sol | 0xb088f8926ae002b7f337b6a93ddc2209882ef378 | Solidity | ERC721Enumerable | abstract contract ERC721Enumerable is ERC721, IERC721Enumerable {
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override(IERC165, ERC721) returns (bool) {
return interfaceId == type(IERC721Enumerable).interfaceId || super.supportsInterface(interfaceId);
}
/**
* @dev See {IERC721Enumerable-totalSupply}.
*/
function totalSupply() public view virtual override returns (uint256) {
return _owners.length;
}
/**
* @dev See {IERC721Enumerable-tokenByIndex}.
*/
function tokenByIndex(uint256 index) public view virtual override returns (uint256) {
require(index < _owners.length, "ERC721Enumerable: global index out of bounds");
return index;
}
/**
* @dev See {IERC721Enumerable-tokenOfOwnerByIndex}.
*/
function tokenOfOwnerByIndex(address owner, uint256 index) public view virtual override returns (uint256 tokenId) {
require(index < balanceOf(owner), "ERC721Enumerable: owner index out of bounds");
uint count;
for(uint i; i < _owners.length; i++){
if(owner == _owners[i]){
if(count == index) return i;
else count++;
}
}
revert("ERC721Enumerable: owner index out of bounds");
}
} | /**
* @dev This implements an optional extension of {ERC721} defined in the EIP that adds
* enumerability of all the token ids in the contract as well as all token ids owned by each
* account but rips out the core of the gas-wasting processing that comes from OpenZeppelin.
*/ | NatSpecMultiLine | totalSupply | function totalSupply() public view virtual override returns (uint256) {
return _owners.length;
}
| /**
* @dev See {IERC721Enumerable-totalSupply}.
*/ | NatSpecMultiLine | v0.8.7+commit.e28d00a7 | {
"func_code_index": [
431,
546
]
} | 2,560 |
||
WalkingApe | contracts/ERC721Enumerable.sol | 0xb088f8926ae002b7f337b6a93ddc2209882ef378 | Solidity | ERC721Enumerable | abstract contract ERC721Enumerable is ERC721, IERC721Enumerable {
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override(IERC165, ERC721) returns (bool) {
return interfaceId == type(IERC721Enumerable).interfaceId || super.supportsInterface(interfaceId);
}
/**
* @dev See {IERC721Enumerable-totalSupply}.
*/
function totalSupply() public view virtual override returns (uint256) {
return _owners.length;
}
/**
* @dev See {IERC721Enumerable-tokenByIndex}.
*/
function tokenByIndex(uint256 index) public view virtual override returns (uint256) {
require(index < _owners.length, "ERC721Enumerable: global index out of bounds");
return index;
}
/**
* @dev See {IERC721Enumerable-tokenOfOwnerByIndex}.
*/
function tokenOfOwnerByIndex(address owner, uint256 index) public view virtual override returns (uint256 tokenId) {
require(index < balanceOf(owner), "ERC721Enumerable: owner index out of bounds");
uint count;
for(uint i; i < _owners.length; i++){
if(owner == _owners[i]){
if(count == index) return i;
else count++;
}
}
revert("ERC721Enumerable: owner index out of bounds");
}
} | /**
* @dev This implements an optional extension of {ERC721} defined in the EIP that adds
* enumerability of all the token ids in the contract as well as all token ids owned by each
* account but rips out the core of the gas-wasting processing that comes from OpenZeppelin.
*/ | NatSpecMultiLine | tokenByIndex | function tokenByIndex(uint256 index) public view virtual override returns (uint256) {
require(index < _owners.length, "ERC721Enumerable: global index out of bounds");
return index;
}
| /**
* @dev See {IERC721Enumerable-tokenByIndex}.
*/ | NatSpecMultiLine | v0.8.7+commit.e28d00a7 | {
"func_code_index": [
618,
828
]
} | 2,561 |
||
WalkingApe | contracts/ERC721Enumerable.sol | 0xb088f8926ae002b7f337b6a93ddc2209882ef378 | Solidity | ERC721Enumerable | abstract contract ERC721Enumerable is ERC721, IERC721Enumerable {
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override(IERC165, ERC721) returns (bool) {
return interfaceId == type(IERC721Enumerable).interfaceId || super.supportsInterface(interfaceId);
}
/**
* @dev See {IERC721Enumerable-totalSupply}.
*/
function totalSupply() public view virtual override returns (uint256) {
return _owners.length;
}
/**
* @dev See {IERC721Enumerable-tokenByIndex}.
*/
function tokenByIndex(uint256 index) public view virtual override returns (uint256) {
require(index < _owners.length, "ERC721Enumerable: global index out of bounds");
return index;
}
/**
* @dev See {IERC721Enumerable-tokenOfOwnerByIndex}.
*/
function tokenOfOwnerByIndex(address owner, uint256 index) public view virtual override returns (uint256 tokenId) {
require(index < balanceOf(owner), "ERC721Enumerable: owner index out of bounds");
uint count;
for(uint i; i < _owners.length; i++){
if(owner == _owners[i]){
if(count == index) return i;
else count++;
}
}
revert("ERC721Enumerable: owner index out of bounds");
}
} | /**
* @dev This implements an optional extension of {ERC721} defined in the EIP that adds
* enumerability of all the token ids in the contract as well as all token ids owned by each
* account but rips out the core of the gas-wasting processing that comes from OpenZeppelin.
*/ | NatSpecMultiLine | tokenOfOwnerByIndex | function tokenOfOwnerByIndex(address owner, uint256 index) public view virtual override returns (uint256 tokenId) {
require(index < balanceOf(owner), "ERC721Enumerable: owner index out of bounds");
uint count;
for(uint i; i < _owners.length; i++){
if(owner == _owners[i]){
if(count == index) return i;
else count++;
}
}
revert("ERC721Enumerable: owner index out of bounds");
}
| /**
* @dev See {IERC721Enumerable-tokenOfOwnerByIndex}.
*/ | NatSpecMultiLine | v0.8.7+commit.e28d00a7 | {
"func_code_index": [
907,
1402
]
} | 2,562 |
||
PlayboyShibaToken | PlayboyShibaToken.sol | 0xa8f5621aa765f454f32201de526c54951c098046 | 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.
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
/**
* @dev Emitted when `value` tokens are moved from one account (`from`)
* to another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
} | /**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/ | NatSpecMultiLine | totalSupply | function totalSupply() external view returns (uint256);
| /**
* @dev Returns the amount of tokens in existence.
*/ | NatSpecMultiLine | v0.8.6+commit.11564f7e | MIT | ipfs://c01518611325b255d0c1f35c2d0900eced9cfd3642c4c42ef7a2b64650e21d44 | {
"func_code_index": [
94,
154
]
} | 2,563 |
PlayboyShibaToken | PlayboyShibaToken.sol | 0xa8f5621aa765f454f32201de526c54951c098046 | 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.
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
/**
* @dev Emitted when `value` tokens are moved from one account (`from`)
* to another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
} | /**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/ | NatSpecMultiLine | balanceOf | function balanceOf(address account) external view returns (uint256);
| /**
* @dev Returns the amount of tokens owned by `account`.
*/ | NatSpecMultiLine | v0.8.6+commit.11564f7e | MIT | ipfs://c01518611325b255d0c1f35c2d0900eced9cfd3642c4c42ef7a2b64650e21d44 | {
"func_code_index": [
237,
310
]
} | 2,564 |
PlayboyShibaToken | PlayboyShibaToken.sol | 0xa8f5621aa765f454f32201de526c54951c098046 | 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.
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
/**
* @dev Emitted when `value` tokens are moved from one account (`from`)
* to another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
} | /**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/ | NatSpecMultiLine | transfer | function transfer(address recipient, uint256 amount) external returns (bool);
| /**
* @dev Moves `amount` tokens from the caller's account to `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/ | NatSpecMultiLine | v0.8.6+commit.11564f7e | MIT | ipfs://c01518611325b255d0c1f35c2d0900eced9cfd3642c4c42ef7a2b64650e21d44 | {
"func_code_index": [
534,
616
]
} | 2,565 |
PlayboyShibaToken | PlayboyShibaToken.sol | 0xa8f5621aa765f454f32201de526c54951c098046 | 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.
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
/**
* @dev Emitted when `value` tokens are moved from one account (`from`)
* to another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
} | /**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/ | NatSpecMultiLine | allowance | function allowance(address owner, address spender) external view returns (uint256);
| /**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}.
* This is zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/ | NatSpecMultiLine | v0.8.6+commit.11564f7e | MIT | ipfs://c01518611325b255d0c1f35c2d0900eced9cfd3642c4c42ef7a2b64650e21d44 | {
"func_code_index": [
895,
983
]
} | 2,566 |
PlayboyShibaToken | PlayboyShibaToken.sol | 0xa8f5621aa765f454f32201de526c54951c098046 | 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.
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
/**
* @dev Emitted when `value` tokens are moved from one account (`from`)
* to another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
} | /**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/ | NatSpecMultiLine | approve | function approve(address spender, uint256 amount) external returns (bool);
| /**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits an {Approval} event.
*/ | NatSpecMultiLine | v0.8.6+commit.11564f7e | MIT | ipfs://c01518611325b255d0c1f35c2d0900eced9cfd3642c4c42ef7a2b64650e21d44 | {
"func_code_index": [
1214,
1293
]
} | 2,567 |
PlayboyShibaToken | PlayboyShibaToken.sol | 0xa8f5621aa765f454f32201de526c54951c098046 | 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.
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
/**
* @dev Emitted when `value` tokens are moved from one account (`from`)
* to another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
} | /**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/ | NatSpecMultiLine | transferFrom | function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
| /**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/ | NatSpecMultiLine | v0.8.6+commit.11564f7e | MIT | ipfs://c01518611325b255d0c1f35c2d0900eced9cfd3642c4c42ef7a2b64650e21d44 | {
"func_code_index": [
1606,
1708
]
} | 2,568 |
PlayboyShibaToken | PlayboyShibaToken.sol | 0xa8f5621aa765f454f32201de526c54951c098046 | Solidity | SafeMath | library SafeMath {
/**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*/
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.
*/
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.
*/
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.
*/
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).
*/
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).
*/
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).
*/
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).
*/
function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b != 0, errorMessage);
return a % b;
}
} | /**
* @dev Wrappers over Solidity's arithmetic operations with added overflow
* checks.
*
* Arithmetic operations in Solidity wrap on overflow. This can easily result
* in bugs, because programmers usually assume that an overflow raises an
* error, which is the standard behavior in high level programming languages.
* `SafeMath` restores this intuition by reverting the transaction when an
* operation overflows.
*
* Using this library instead of the unchecked operations eliminates an entire
* class of bugs, so it's recommended to use it always.
*/ | NatSpecMultiLine | 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.
*/ | NatSpecMultiLine | v0.8.6+commit.11564f7e | MIT | ipfs://c01518611325b255d0c1f35c2d0900eced9cfd3642c4c42ef7a2b64650e21d44 | {
"func_code_index": [
185,
369
]
} | 2,569 |
PlayboyShibaToken | PlayboyShibaToken.sol | 0xa8f5621aa765f454f32201de526c54951c098046 | Solidity | SafeMath | library SafeMath {
/**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*/
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.
*/
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.
*/
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.
*/
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).
*/
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).
*/
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).
*/
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).
*/
function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b != 0, errorMessage);
return a % b;
}
} | /**
* @dev Wrappers over Solidity's arithmetic operations with added overflow
* checks.
*
* Arithmetic operations in Solidity wrap on overflow. This can easily result
* in bugs, because programmers usually assume that an overflow raises an
* error, which is the standard behavior in high level programming languages.
* `SafeMath` restores this intuition by reverting the transaction when an
* operation overflows.
*
* Using this library instead of the unchecked operations eliminates an entire
* class of bugs, so it's recommended to use it always.
*/ | NatSpecMultiLine | 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.
*/ | NatSpecMultiLine | v0.8.6+commit.11564f7e | MIT | ipfs://c01518611325b255d0c1f35c2d0900eced9cfd3642c4c42ef7a2b64650e21d44 | {
"func_code_index": [
570,
711
]
} | 2,570 |
PlayboyShibaToken | PlayboyShibaToken.sol | 0xa8f5621aa765f454f32201de526c54951c098046 | Solidity | SafeMath | library SafeMath {
/**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*/
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.
*/
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.
*/
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.
*/
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).
*/
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).
*/
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).
*/
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).
*/
function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b != 0, errorMessage);
return a % b;
}
} | /**
* @dev Wrappers over Solidity's arithmetic operations with added overflow
* checks.
*
* Arithmetic operations in Solidity wrap on overflow. This can easily result
* in bugs, because programmers usually assume that an overflow raises an
* error, which is the standard behavior in high level programming languages.
* `SafeMath` restores this intuition by reverting the transaction when an
* operation overflows.
*
* Using this library instead of the unchecked operations eliminates an entire
* class of bugs, so it's recommended to use it always.
*/ | NatSpecMultiLine | 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.
*/ | NatSpecMultiLine | v0.8.6+commit.11564f7e | MIT | ipfs://c01518611325b255d0c1f35c2d0900eced9cfd3642c4c42ef7a2b64650e21d44 | {
"func_code_index": [
932,
1127
]
} | 2,571 |
PlayboyShibaToken | PlayboyShibaToken.sol | 0xa8f5621aa765f454f32201de526c54951c098046 | Solidity | SafeMath | library SafeMath {
/**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*/
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.
*/
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.
*/
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.
*/
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).
*/
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).
*/
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).
*/
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).
*/
function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b != 0, errorMessage);
return a % b;
}
} | /**
* @dev Wrappers over Solidity's arithmetic operations with added overflow
* checks.
*
* Arithmetic operations in Solidity wrap on overflow. This can easily result
* in bugs, because programmers usually assume that an overflow raises an
* error, which is the standard behavior in high level programming languages.
* `SafeMath` restores this intuition by reverting the transaction when an
* operation overflows.
*
* Using this library instead of the unchecked operations eliminates an entire
* class of bugs, so it's recommended to use it always.
*/ | 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.
// 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.
*/ | NatSpecMultiLine | v0.8.6+commit.11564f7e | MIT | ipfs://c01518611325b255d0c1f35c2d0900eced9cfd3642c4c42ef7a2b64650e21d44 | {
"func_code_index": [
1301,
1773
]
} | 2,572 |
PlayboyShibaToken | PlayboyShibaToken.sol | 0xa8f5621aa765f454f32201de526c54951c098046 | Solidity | SafeMath | library SafeMath {
/**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*/
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.
*/
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.
*/
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.
*/
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).
*/
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).
*/
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).
*/
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).
*/
function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b != 0, errorMessage);
return a % b;
}
} | /**
* @dev Wrappers over Solidity's arithmetic operations with added overflow
* checks.
*
* Arithmetic operations in Solidity wrap on overflow. This can easily result
* in bugs, because programmers usually assume that an overflow raises an
* error, which is the standard behavior in high level programming languages.
* `SafeMath` restores this intuition by reverting the transaction when an
* operation overflows.
*
* Using this library instead of the unchecked operations eliminates an entire
* class of bugs, so it's recommended to use it always.
*/ | NatSpecMultiLine | 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).
*/ | NatSpecMultiLine | v0.8.6+commit.11564f7e | MIT | ipfs://c01518611325b255d0c1f35c2d0900eced9cfd3642c4c42ef7a2b64650e21d44 | {
"func_code_index": [
2168,
2305
]
} | 2,573 |
PlayboyShibaToken | PlayboyShibaToken.sol | 0xa8f5621aa765f454f32201de526c54951c098046 | Solidity | SafeMath | library SafeMath {
/**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*/
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.
*/
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.
*/
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.
*/
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).
*/
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).
*/
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).
*/
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).
*/
function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b != 0, errorMessage);
return a % b;
}
} | /**
* @dev Wrappers over Solidity's arithmetic operations with added overflow
* checks.
*
* Arithmetic operations in Solidity wrap on overflow. This can easily result
* in bugs, because programmers usually assume that an overflow raises an
* error, which is the standard behavior in high level programming languages.
* `SafeMath` restores this intuition by reverting the transaction when an
* operation overflows.
*
* Using this library instead of the unchecked operations eliminates an entire
* class of bugs, so it's recommended to use it always.
*/ | NatSpecMultiLine | 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).
*/ | NatSpecMultiLine | v0.8.6+commit.11564f7e | MIT | ipfs://c01518611325b255d0c1f35c2d0900eced9cfd3642c4c42ef7a2b64650e21d44 | {
"func_code_index": [
2720,
3001
]
} | 2,574 |
PlayboyShibaToken | PlayboyShibaToken.sol | 0xa8f5621aa765f454f32201de526c54951c098046 | Solidity | SafeMath | library SafeMath {
/**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*/
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.
*/
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.
*/
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.
*/
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).
*/
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).
*/
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).
*/
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).
*/
function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b != 0, errorMessage);
return a % b;
}
} | /**
* @dev Wrappers over Solidity's arithmetic operations with added overflow
* checks.
*
* Arithmetic operations in Solidity wrap on overflow. This can easily result
* in bugs, because programmers usually assume that an overflow raises an
* error, which is the standard behavior in high level programming languages.
* `SafeMath` restores this intuition by reverting the transaction when an
* operation overflows.
*
* Using this library instead of the unchecked operations eliminates an entire
* class of bugs, so it's recommended to use it always.
*/ | NatSpecMultiLine | 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).
*/ | NatSpecMultiLine | v0.8.6+commit.11564f7e | MIT | ipfs://c01518611325b255d0c1f35c2d0900eced9cfd3642c4c42ef7a2b64650e21d44 | {
"func_code_index": [
3385,
3520
]
} | 2,575 |
PlayboyShibaToken | PlayboyShibaToken.sol | 0xa8f5621aa765f454f32201de526c54951c098046 | Solidity | SafeMath | library SafeMath {
/**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*/
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.
*/
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.
*/
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.
*/
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).
*/
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).
*/
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).
*/
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).
*/
function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b != 0, errorMessage);
return a % b;
}
} | /**
* @dev Wrappers over Solidity's arithmetic operations with added overflow
* checks.
*
* Arithmetic operations in Solidity wrap on overflow. This can easily result
* in bugs, because programmers usually assume that an overflow raises an
* error, which is the standard behavior in high level programming languages.
* `SafeMath` restores this intuition by reverting the transaction when an
* operation overflows.
*
* Using this library instead of the unchecked operations eliminates an entire
* class of bugs, so it's recommended to use it always.
*/ | NatSpecMultiLine | 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).
*/ | NatSpecMultiLine | v0.8.6+commit.11564f7e | MIT | ipfs://c01518611325b255d0c1f35c2d0900eced9cfd3642c4c42ef7a2b64650e21d44 | {
"func_code_index": [
3924,
4095
]
} | 2,576 |
PlayboyShibaToken | PlayboyShibaToken.sol | 0xa8f5621aa765f454f32201de526c54951c098046 | Solidity | Address | library Address {
/**
* @dev Returns true if `account` is a contract.
*/
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.
*/
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.
*/
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.
*/
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`.
*/
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.
*/
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 | isContract | 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 Returns true if `account` is a contract.
*/ | NatSpecMultiLine | v0.8.6+commit.11564f7e | MIT | ipfs://c01518611325b255d0c1f35c2d0900eced9cfd3642c4c42ef7a2b64650e21d44 | {
"func_code_index": [
91,
518
]
} | 2,577 |
PlayboyShibaToken | PlayboyShibaToken.sol | 0xa8f5621aa765f454f32201de526c54951c098046 | Solidity | Address | library Address {
/**
* @dev Returns true if `account` is a contract.
*/
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.
*/
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.
*/
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.
*/
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`.
*/
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.
*/
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 | 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.
*/ | NatSpecMultiLine | v0.8.6+commit.11564f7e | MIT | ipfs://c01518611325b255d0c1f35c2d0900eced9cfd3642c4c42ef7a2b64650e21d44 | {
"func_code_index": [
688,
1090
]
} | 2,578 |
PlayboyShibaToken | PlayboyShibaToken.sol | 0xa8f5621aa765f454f32201de526c54951c098046 | Solidity | Address | library Address {
/**
* @dev Returns true if `account` is a contract.
*/
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.
*/
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.
*/
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.
*/
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`.
*/
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.
*/
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) 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.
*/ | NatSpecMultiLine | v0.8.6+commit.11564f7e | MIT | ipfs://c01518611325b255d0c1f35c2d0900eced9cfd3642c4c42ef7a2b64650e21d44 | {
"func_code_index": [
1474,
1652
]
} | 2,579 |
PlayboyShibaToken | PlayboyShibaToken.sol | 0xa8f5621aa765f454f32201de526c54951c098046 | Solidity | Address | library Address {
/**
* @dev Returns true if `account` is a contract.
*/
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.
*/
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.
*/
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.
*/
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`.
*/
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.
*/
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.
*/ | NatSpecMultiLine | v0.8.6+commit.11564f7e | MIT | ipfs://c01518611325b255d0c1f35c2d0900eced9cfd3642c4c42ef7a2b64650e21d44 | {
"func_code_index": [
1837,
2038
]
} | 2,580 |
PlayboyShibaToken | PlayboyShibaToken.sol | 0xa8f5621aa765f454f32201de526c54951c098046 | Solidity | Address | library Address {
/**
* @dev Returns true if `account` is a contract.
*/
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.
*/
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.
*/
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.
*/
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`.
*/
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.
*/
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`.
*/ | NatSpecMultiLine | v0.8.6+commit.11564f7e | MIT | ipfs://c01518611325b255d0c1f35c2d0900eced9cfd3642c4c42ef7a2b64650e21d44 | {
"func_code_index": [
2195,
2426
]
} | 2,581 |
PlayboyShibaToken | PlayboyShibaToken.sol | 0xa8f5621aa765f454f32201de526c54951c098046 | Solidity | Address | library Address {
/**
* @dev Returns true if `account` is a contract.
*/
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.
*/
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.
*/
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.
*/
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`.
*/
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.
*/
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.
*/ | NatSpecMultiLine | v0.8.6+commit.11564f7e | MIT | ipfs://c01518611325b255d0c1f35c2d0900eced9cfd3642c4c42ef7a2b64650e21d44 | {
"func_code_index": [
2637,
2958
]
} | 2,582 |
PlayboyShibaToken | PlayboyShibaToken.sol | 0xa8f5621aa765f454f32201de526c54951c098046 | 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 () {
address msgSender = _msgSender();
_owner = msgSender;
emit OwnershipTransferred(address(0), msgSender);
}
/**
* @dev Returns the address of the current owner.
*/
modifier onlyOwner() {
require(_owner == _msgSender(), "Ownable: caller is not the owner");
_;
}
/**
* @dev Throws if called by any account other than the owner.
*/
function owner() internal view returns (address) {
return _owner;
}
} | /**
* @dev Contract module which provides a basic access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* By default, the owner account will be the one that deploys the contract.
*
* This module is used through inheritance. It will make available the modifier
* `onlyOwner`, which can be applied to your functions to restrict their use to
* the owner.
*/ | NatSpecMultiLine | owner | function owner() internal view returns (address) {
return _owner;
}
| /**
* @dev Throws if called by any account other than the owner.
*/ | NatSpecMultiLine | v0.8.6+commit.11564f7e | MIT | ipfs://c01518611325b255d0c1f35c2d0900eced9cfd3642c4c42ef7a2b64650e21d44 | {
"func_code_index": [
706,
792
]
} | 2,583 |
PuppyFrunk | PuppyFrunk.sol | 0x5054288fbaf74fe608fd612300c4196d3370966b | 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://2da08609a5eaa22adc87cca9854667e5b89c57d7fa813e63a2a3fedff1868974 | {
"func_code_index": [
104,
168
]
} | 2,584 |
||
PuppyFrunk | PuppyFrunk.sol | 0x5054288fbaf74fe608fd612300c4196d3370966b | 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://2da08609a5eaa22adc87cca9854667e5b89c57d7fa813e63a2a3fedff1868974 | {
"func_code_index": [
261,
338
]
} | 2,585 |
||
PuppyFrunk | PuppyFrunk.sol | 0x5054288fbaf74fe608fd612300c4196d3370966b | 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://2da08609a5eaa22adc87cca9854667e5b89c57d7fa813e63a2a3fedff1868974 | {
"func_code_index": [
584,
670
]
} | 2,586 |
||
PuppyFrunk | PuppyFrunk.sol | 0x5054288fbaf74fe608fd612300c4196d3370966b | 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://2da08609a5eaa22adc87cca9854667e5b89c57d7fa813e63a2a3fedff1868974 | {
"func_code_index": [
971,
1063
]
} | 2,587 |
||
PuppyFrunk | PuppyFrunk.sol | 0x5054288fbaf74fe608fd612300c4196d3370966b | 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://2da08609a5eaa22adc87cca9854667e5b89c57d7fa813e63a2a3fedff1868974 | {
"func_code_index": [
1770,
1853
]
} | 2,588 |
||
PuppyFrunk | PuppyFrunk.sol | 0x5054288fbaf74fe608fd612300c4196d3370966b | 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://2da08609a5eaa22adc87cca9854667e5b89c57d7fa813e63a2a3fedff1868974 | {
"func_code_index": [
2194,
2300
]
} | 2,589 |
||
PuppyFrunk | PuppyFrunk.sol | 0x5054288fbaf74fe608fd612300c4196d3370966b | 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://2da08609a5eaa22adc87cca9854667e5b89c57d7fa813e63a2a3fedff1868974 | {
"func_code_index": [
290,
496
]
} | 2,590 |
||
PuppyFrunk | PuppyFrunk.sol | 0x5054288fbaf74fe608fd612300c4196d3370966b | 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://2da08609a5eaa22adc87cca9854667e5b89c57d7fa813e63a2a3fedff1868974 | {
"func_code_index": [
805,
958
]
} | 2,591 |
||
PuppyFrunk | PuppyFrunk.sol | 0x5054288fbaf74fe608fd612300c4196d3370966b | 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://2da08609a5eaa22adc87cca9854667e5b89c57d7fa813e63a2a3fedff1868974 | {
"func_code_index": [
1287,
1504
]
} | 2,592 |
||
PuppyFrunk | PuppyFrunk.sol | 0x5054288fbaf74fe608fd612300c4196d3370966b | 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://2da08609a5eaa22adc87cca9854667e5b89c57d7fa813e63a2a3fedff1868974 | {
"func_code_index": [
1789,
2309
]
} | 2,593 |
||
PuppyFrunk | PuppyFrunk.sol | 0x5054288fbaf74fe608fd612300c4196d3370966b | 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://2da08609a5eaa22adc87cca9854667e5b89c57d7fa813e63a2a3fedff1868974 | {
"func_code_index": [
2817,
2966
]
} | 2,594 |
||
PuppyFrunk | PuppyFrunk.sol | 0x5054288fbaf74fe608fd612300c4196d3370966b | 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://2da08609a5eaa22adc87cca9854667e5b89c57d7fa813e63a2a3fedff1868974 | {
"func_code_index": [
3494,
3801
]
} | 2,595 |
||
PuppyFrunk | PuppyFrunk.sol | 0x5054288fbaf74fe608fd612300c4196d3370966b | 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://2da08609a5eaa22adc87cca9854667e5b89c57d7fa813e63a2a3fedff1868974 | {
"func_code_index": [
4298,
4445
]
} | 2,596 |
||
PuppyFrunk | PuppyFrunk.sol | 0x5054288fbaf74fe608fd612300c4196d3370966b | 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://2da08609a5eaa22adc87cca9854667e5b89c57d7fa813e63a2a3fedff1868974 | {
"func_code_index": [
4962,
5149
]
} | 2,597 |
||
PuppyFrunk | PuppyFrunk.sol | 0x5054288fbaf74fe608fd612300c4196d3370966b | 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://2da08609a5eaa22adc87cca9854667e5b89c57d7fa813e63a2a3fedff1868974 | {
"func_code_index": [
658,
1322
]
} | 2,598 |
||
PuppyFrunk | PuppyFrunk.sol | 0x5054288fbaf74fe608fd612300c4196d3370966b | 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://2da08609a5eaa22adc87cca9854667e5b89c57d7fa813e63a2a3fedff1868974 | {
"func_code_index": [
2301,
2727
]
} | 2,599 |
||
PuppyFrunk | PuppyFrunk.sol | 0x5054288fbaf74fe608fd612300c4196d3370966b | 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://2da08609a5eaa22adc87cca9854667e5b89c57d7fa813e63a2a3fedff1868974 | {
"func_code_index": [
3538,
3726
]
} | 2,600 |
||
PuppyFrunk | PuppyFrunk.sol | 0x5054288fbaf74fe608fd612300c4196d3370966b | 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://2da08609a5eaa22adc87cca9854667e5b89c57d7fa813e63a2a3fedff1868974 | {
"func_code_index": [
3970,
4183
]
} | 2,601 |
||
PuppyFrunk | PuppyFrunk.sol | 0x5054288fbaf74fe608fd612300c4196d3370966b | 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://2da08609a5eaa22adc87cca9854667e5b89c57d7fa813e63a2a3fedff1868974 | {
"func_code_index": [
4587,
4830
]
} | 2,602 |
||
PuppyFrunk | PuppyFrunk.sol | 0x5054288fbaf74fe608fd612300c4196d3370966b | 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://2da08609a5eaa22adc87cca9854667e5b89c57d7fa813e63a2a3fedff1868974 | {
"func_code_index": [
5100,
5437
]
} | 2,603 |
||
PuppyFrunk | PuppyFrunk.sol | 0x5054288fbaf74fe608fd612300c4196d3370966b | Solidity | Ownable | contract Ownable is Context {
address private _owner;
address private _previousOwner;
uint256 private _lockTime;
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;
}
function geUnlockTime() public view returns (uint256) {
return _lockTime;
}
//Locks the contract for owner for the amount of time provided
function lock(uint256 time) public virtual onlyOwner {
_previousOwner = _owner;
_owner = address(0);
_lockTime = now + time;
emit OwnershipTransferred(_owner, address(0));
}
//Unlocks the contract for owner when _lockTime is exceeds
function unlock() public virtual {
require(_previousOwner == msg.sender, "You don't have permission to unlock");
require(now > _lockTime , "Contract is locked until 7 days");
emit OwnershipTransferred(_owner, _previousOwner);
_owner = _previousOwner;
}
} | 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://2da08609a5eaa22adc87cca9854667e5b89c57d7fa813e63a2a3fedff1868974 | {
"func_code_index": [
622,
718
]
} | 2,604 |
||
PuppyFrunk | PuppyFrunk.sol | 0x5054288fbaf74fe608fd612300c4196d3370966b | Solidity | Ownable | contract Ownable is Context {
address private _owner;
address private _previousOwner;
uint256 private _lockTime;
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;
}
function geUnlockTime() public view returns (uint256) {
return _lockTime;
}
//Locks the contract for owner for the amount of time provided
function lock(uint256 time) public virtual onlyOwner {
_previousOwner = _owner;
_owner = address(0);
_lockTime = now + time;
emit OwnershipTransferred(_owner, address(0));
}
//Unlocks the contract for owner when _lockTime is exceeds
function unlock() public virtual {
require(_previousOwner == msg.sender, "You don't have permission to unlock");
require(now > _lockTime , "Contract is locked until 7 days");
emit OwnershipTransferred(_owner, _previousOwner);
_owner = _previousOwner;
}
} | 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://2da08609a5eaa22adc87cca9854667e5b89c57d7fa813e63a2a3fedff1868974 | {
"func_code_index": [
1324,
1493
]
} | 2,605 |
||
PuppyFrunk | PuppyFrunk.sol | 0x5054288fbaf74fe608fd612300c4196d3370966b | Solidity | Ownable | contract Ownable is Context {
address private _owner;
address private _previousOwner;
uint256 private _lockTime;
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;
}
function geUnlockTime() public view returns (uint256) {
return _lockTime;
}
//Locks the contract for owner for the amount of time provided
function lock(uint256 time) public virtual onlyOwner {
_previousOwner = _owner;
_owner = address(0);
_lockTime = now + time;
emit OwnershipTransferred(_owner, address(0));
}
//Unlocks the contract for owner when _lockTime is exceeds
function unlock() public virtual {
require(_previousOwner == msg.sender, "You don't have permission to unlock");
require(now > _lockTime , "Contract is locked until 7 days");
emit OwnershipTransferred(_owner, _previousOwner);
_owner = _previousOwner;
}
} | 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://2da08609a5eaa22adc87cca9854667e5b89c57d7fa813e63a2a3fedff1868974 | {
"func_code_index": [
1656,
1925
]
} | 2,606 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.