Warning! Contract bytecode has been changed and doesn't match the verified one. Therefore, interaction with this smart contract may be risky.
- Contract name:
- FAUCET_ETHTipeiHackathon2023
- Optimization enabled
- false
- Compiler version
- v0.8.17+commit.8df45f5f
- EVM Version
- default
- Verified at
- 2023-04-23T00:40:00.211311Z
Contract source code
// File: @openzeppelin\contracts\utils\Address.sol // SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (utils/Address.sol) pragma solidity ^0.8.1; /** * @dev Collection of functions related to the address type */ 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 * ==== * * [IMPORTANT] * ==== * You shouldn't rely on `isContract` to protect against flash loan attacks! * * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract * constructor. * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize/address.code.length, which returns 0 // for contracts in construction, since the code is only stored at the end // of the constructor execution. return account.code.length > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (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 functionCallWithValue(target, data, 0, "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"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResultFromTarget(target, success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResultFromTarget(target, success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResultFromTarget(target, success, returndata, errorMessage); } /** * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract. * * _Available since v4.8._ */ function verifyCallResultFromTarget( address target, bool success, bytes memory returndata, string memory errorMessage ) internal view returns (bytes memory) { if (success) { if (returndata.length == 0) { // only check isContract if the call was successful and the return data is empty // otherwise we already know that it was a contract require(isContract(target), "Address: call to non-contract"); } return returndata; } else { _revert(returndata, errorMessage); } } /** * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason or using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { _revert(returndata, errorMessage); } } function _revert(bytes memory returndata, string memory errorMessage) private pure { // 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 /// @solidity memory-safe-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } // File: contracts\MyContract.sol pragma solidity ^0.8.17; contract FAUCET_ETHTipeiHackathon2023 { using Address for address payable; //limit mint times mapping(address => bool) public hasWithdrawn; receive() external payable { //you can deposit ETH } //Check contract balance function getBalance() public view returns (uint256) { return address(this).balance; } //you only can mint 1 times function withdrawMoney() public { require( !hasWithdrawn[msg.sender], "You have already claimed this reward" ); hasWithdrawn[msg.sender] = true; address payable to = payable(msg.sender); require(address(this).balance >= 0.5 ether, "Insufficient balance"); to.transfer(0.5 ether); } }
Contract ABI
[{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"getBalance","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"hasWithdrawn","inputs":[{"type":"address","name":"","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"withdrawMoney","inputs":[]},{"type":"receive","stateMutability":"payable"}]
Contract Creation Code
0x608060405234801561001057600080fd5b506104af806100206000396000f3fe6080604052600436106100385760003560e01c806312065fe0146100445780635e2c19db1461006f578063ac446002146100ac5761003f565b3661003f57005b600080fd5b34801561005057600080fd5b506100596100c3565b6040516100669190610289565b60405180910390f35b34801561007b57600080fd5b5061009660048036038101906100919190610307565b6100cb565b6040516100a3919061034f565b60405180910390f35b3480156100b857600080fd5b506100c16100eb565b005b600047905090565b60006020528060005260406000206000915054906101000a900460ff1681565b6000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1615610177576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161016e906103ed565b60405180910390fd5b60016000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555060003390506706f05b59d3b2000047101561021e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161021590610459565b60405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff166108fc6706f05b59d3b200009081150290604051600060405180830381858888f1935050505015801561026c573d6000803e3d6000fd5b5050565b6000819050919050565b61028381610270565b82525050565b600060208201905061029e600083018461027a565b92915050565b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b60006102d4826102a9565b9050919050565b6102e4816102c9565b81146102ef57600080fd5b50565b600081359050610301816102db565b92915050565b60006020828403121561031d5761031c6102a4565b5b600061032b848285016102f2565b91505092915050565b60008115159050919050565b61034981610334565b82525050565b60006020820190506103646000830184610340565b92915050565b600082825260208201905092915050565b7f596f75206861766520616c726561647920636c61696d6564207468697320726560008201527f7761726400000000000000000000000000000000000000000000000000000000602082015250565b60006103d760248361036a565b91506103e28261037b565b604082019050919050565b60006020820190508181036000830152610406816103ca565b9050919050565b7f496e73756666696369656e742062616c616e6365000000000000000000000000600082015250565b600061044360148361036a565b915061044e8261040d565b602082019050919050565b6000602082019050818103600083015261047281610436565b905091905056fea2646970667358221220ece5aa32dc1a60a92f38dcbda50ffa9656af291f81cc8663e61e14c1cea31d4264736f6c63430008110033
Deployed ByteCode
0x6080604052600436106100385760003560e01c806312065fe0146100445780635e2c19db1461006f578063ac446002146100ac5761003f565b3661003f57005b600080fd5b34801561005057600080fd5b506100596100c3565b6040516100669190610289565b60405180910390f35b34801561007b57600080fd5b5061009660048036038101906100919190610307565b6100cb565b6040516100a3919061034f565b60405180910390f35b3480156100b857600080fd5b506100c16100eb565b005b600047905090565b60006020528060005260406000206000915054906101000a900460ff1681565b6000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1615610177576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161016e906103ed565b60405180910390fd5b60016000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555060003390506706f05b59d3b2000047101561021e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161021590610459565b60405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff166108fc6706f05b59d3b200009081150290604051600060405180830381858888f1935050505015801561026c573d6000803e3d6000fd5b5050565b6000819050919050565b61028381610270565b82525050565b600060208201905061029e600083018461027a565b92915050565b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b60006102d4826102a9565b9050919050565b6102e4816102c9565b81146102ef57600080fd5b50565b600081359050610301816102db565b92915050565b60006020828403121561031d5761031c6102a4565b5b600061032b848285016102f2565b91505092915050565b60008115159050919050565b61034981610334565b82525050565b60006020820190506103646000830184610340565b92915050565b600082825260208201905092915050565b7f596f75206861766520616c726561647920636c61696d6564207468697320726560008201527f7761726400000000000000000000000000000000000000000000000000000000602082015250565b60006103d760248361036a565b91506103e28261037b565b604082019050919050565b60006020820190508181036000830152610406816103ca565b9050919050565b7f496e73756666696369656e742062616c616e6365000000000000000000000000600082015250565b600061044360148361036a565b915061044e8261040d565b602082019050919050565b6000602082019050818103600083015261047281610436565b905091905056fea2646970667358221220ece5aa32dc1a60a92f38dcbda50ffa9656af291f81cc8663e61e14c1cea31d4264736f6c63430008110033