Polygon Sponsored slots available. Book your slot here!
Contract Overview
My Name Tag:
Not Available, login to update
[ Download CSV Export ]
Latest 25 internal transaction
[ Download CSV Export ]
Contract Name:
Faucet
Compiler Version
v0.7.6+commit.7338295f
Optimization Enabled:
Yes with 1000 runs
Other Settings:
default evmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; import { Ownable } from "@openzeppelin/contracts/access/Ownable.sol"; import { SafeMath } from "@openzeppelin/contracts/math/SafeMath.sol"; import { IFaucet } from "../../interfaces/IFaucet.sol"; contract Faucet is IFaucet, Ownable { using SafeMath for uint256; uint256 public recipientMinBalance; uint256 public recipientDesiredBalance; mapping (address => bool) public whitelist; event Withdraw(address indexed caller, address indexed to, uint256 amount); event Configure(uint256 recipientMinBalance, uint256 recipientDesiredBalance); event Whitelist(address indexed account, bool whitelisted); event Deposit(address indexed caller, uint256 amount); function isFaucet() override external view returns(bool) { // Shhh compiler warning.. recipientMinBalance; return true; } /** * @dev Deposit */ function deposit() external payable { emit Deposit(msg.sender, msg.value); } /** * @dev Withdraw */ function withdraw(address payable to) override external returns(uint256) { if(whitelist[msg.sender] && to.balance < recipientMinBalance) { uint256 amount = recipientDesiredBalance.sub(to.balance); if(amount > address(this).balance) { amount = address(this).balance; } to.transfer(amount); Withdraw(msg.sender, to, amount); return amount; } else { return 0; } } /** * @dev Configure recipient min and desired balances. * Can only be called by the contract owner. * Emits an {Configure} event. */ function configure(uint256 minBalance, uint256 desiredBalance) external onlyOwner { require(minBalance <= desiredBalance, "Faucet: minBalance <= desiredBalance"); recipientMinBalance = minBalance; recipientDesiredBalance = desiredBalance; emit Configure(minBalance, desiredBalance); } /** * @dev Allows to withdraw contract entire balance. * Can only be called by the contract owner. */ function withdrawAll(address payable to, uint256 amount) external onlyOwner { uint256 finalAmount = amount == 0 || amount > address(this).balance ? address(this).balance : amount; to.transfer(finalAmount); } /** * @dev Sets `account` as whitelisted or not. * Can only be called by the contract owner. * Emits an {Whitelist} event. */ function setWhitelist(address account, bool whitelisted) external onlyOwner { whitelist[account] = whitelisted; emit Whitelist(account, whitelisted); } /** * @dev Disable renounceOwnership functionality */ function renounceOwnership() public virtual override onlyOwner { revert("renounceOwnership disabled"); } /** * @dev Payable fallback */ receive() external payable { } }
// SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; import "../utils/Context.sol"; /** * @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 * can later be changed with {transferOwnership}. * * 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. */ abstract contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor () internal { address msgSender = _msgSender(); _owner = msgSender; emit OwnershipTransferred(address(0), msgSender); } /** * @dev Returns the address of the current owner. */ function owner() public view virtual 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; } }
// SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; /** * @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. */ library SafeMath { /** * @dev Returns the addition of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) { uint256 c = a + b; if (c < a) return (false, 0); return (true, c); } /** * @dev Returns the substraction of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) { if (b > a) return (false, 0); return (true, a - b); } /** * @dev Returns the multiplication of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function tryMul(uint256 a, uint256 b) internal pure returns (bool, 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 (true, 0); uint256 c = a * b; if (c / a != b) return (false, 0); return (true, c); } /** * @dev Returns the division of two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */ function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) { if (b == 0) return (false, 0); return (true, a / b); } /** * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */ function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) { if (b == 0) return (false, 0); return (true, a % b); } /** * @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) { require(b <= a, "SafeMath: subtraction overflow"); return a - b; } /** * @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) { 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, reverting 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) { require(b > 0, "SafeMath: division by zero"); return a / b; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * reverting 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) { require(b > 0, "SafeMath: modulo by zero"); return a % b; } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {trySub}. * * 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); return a - b; } /** * @dev Returns the integer division of two unsigned integers, reverting with custom message on * division by zero. The result is rounded towards zero. * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {tryDiv}. * * 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); return a / b; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * reverting with custom message when dividing by zero. * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {tryMod}. * * 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; } }
// SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; interface IFaucet { function isFaucet() external view returns(bool); function withdraw(address payable recipient) external returns(uint256); }
// SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; /* * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with GSN meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address payable) { return msg.sender; } function _msgData() internal view virtual returns (bytes memory) { this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 return msg.data; } }
{ "optimizer": { "enabled": true, "runs": 1000 }, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } }, "libraries": {} }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
[{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"recipientMinBalance","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"recipientDesiredBalance","type":"uint256"}],"name":"Configure","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"caller","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Deposit","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":false,"internalType":"bool","name":"whitelisted","type":"bool"}],"name":"Whitelist","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"caller","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Withdraw","type":"event"},{"inputs":[{"internalType":"uint256","name":"minBalance","type":"uint256"},{"internalType":"uint256","name":"desiredBalance","type":"uint256"}],"name":"configure","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"deposit","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"isFaucet","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"recipientDesiredBalance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"recipientMinBalance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"bool","name":"whitelisted","type":"bool"}],"name":"setWhitelist","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"whitelist","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address payable","name":"to","type":"address"}],"name":"withdraw","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address payable","name":"to","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"withdrawAll","outputs":[],"stateMutability":"nonpayable","type":"function"},{"stateMutability":"payable","type":"receive"}]
Contract Creation Code
608060405234801561001057600080fd5b50600061001b61006a565b600080546001600160a01b0319166001600160a01b0383169081178255604051929350917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908290a35061006e565b3390565b61097e8061007d6000396000f3fe6080604052600436106100cb5760003560e01c80638da5cb5b11610074578063cc6dbc271161004e578063cc6dbc2714610255578063d0e30db01461028e578063f2fde38b14610296576100d2565b80638da5cb5b146101dc5780639b19251a1461020d578063ab6ab0da14610240576100d2565b806353d6fd59116100a557806353d6fd5914610163578063624763231461019e578063715018a6146101c7576100d2565b80633e32747a146100d757806347bd6c801461010957806351cff8d914610130576100d2565b366100d257005b600080fd5b3480156100e357600080fd5b50610107600480360360408110156100fa57600080fd5b50803590602001356102c9565b005b34801561011557600080fd5b5061011e6103c5565b60408051918252519081900360200190f35b34801561013c57600080fd5b5061011e6004803603602081101561015357600080fd5b50356001600160a01b03166103cb565b34801561016f57600080fd5b506101076004803603604081101561018657600080fd5b506001600160a01b03813516906020013515156104a8565b3480156101aa57600080fd5b506101b361057c565b604080519115158252519081900360200190f35b3480156101d357600080fd5b50610107610581565b3480156101e857600080fd5b506101f1610642565b604080516001600160a01b039092168252519081900360200190f35b34801561021957600080fd5b506101b36004803603602081101561023057600080fd5b50356001600160a01b0316610651565b34801561024c57600080fd5b5061011e610666565b34801561026157600080fd5b506101076004803603604081101561027857600080fd5b506001600160a01b03813516906020013561066c565b610107610739565b3480156102a257600080fd5b50610107600480360360208110156102b957600080fd5b50356001600160a01b0316610771565b6102d161089d565b6001600160a01b03166102e2610642565b6001600160a01b03161461033d576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b8082111561037c5760405162461bcd60e51b81526004018080602001828103825260248152602001806109256024913960400191505060405180910390fd5b60018290556002819055604080518381526020810183905281517fded69ffb8f0bf716c06cc4f6cfc326924bc5af24ca64a0811ef8e38f8c4463e3929181900390910190a15050565b60025481565b3360009081526003602052604081205460ff1680156103f55750600154826001600160a01b031631105b1561049f57600254600090610414906001600160a01b038516316108a1565b9050478111156104215750475b6040516001600160a01b0384169082156108fc029083906000818181858888f19350505050158015610457573d6000803e3d6000fd5b506040805182815290516001600160a01b0385169133917f9b1bfa7fa9ee420a16e124f794c35ac9f90472acc99140eb2f6447c714cad8eb9181900360200190a390506104a3565b5060005b919050565b6104b061089d565b6001600160a01b03166104c1610642565b6001600160a01b03161461051c576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b6001600160a01b038216600081815260036020908152604091829020805460ff1916851515908117909155825190815291517f5a25e09a5dba33161281055e015f1279b6b10204d8f90dd56a8ce2b82322d43d9281900390910190a25050565b600190565b61058961089d565b6001600160a01b031661059a610642565b6001600160a01b0316146105f5576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b6040805162461bcd60e51b815260206004820152601a60248201527f72656e6f756e63654f776e6572736869702064697361626c6564000000000000604482015290519081900360640190fd5b6000546001600160a01b031690565b60036020526000908152604090205460ff1681565b60015481565b61067461089d565b6001600160a01b0316610685610642565b6001600160a01b0316146106e0576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b60008115806106ee57504782115b6106f857816106fa565b475b6040519091506001600160a01b0384169082156108fc029083906000818181858888f19350505050158015610733573d6000803e3d6000fd5b50505050565b60408051348152905133917fe1fffcc4923d04b559f4d29a8bfc6cda04eb5b0d3c460751c2402c5c5cc9109c919081900360200190a2565b61077961089d565b6001600160a01b031661078a610642565b6001600160a01b0316146107e5576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b6001600160a01b03811661082a5760405162461bcd60e51b81526004018080602001828103825260268152602001806108ff6026913960400191505060405180910390fd5b600080546040516001600160a01b03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a3600080547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b0392909216919091179055565b3390565b6000828211156108f8576040805162461bcd60e51b815260206004820152601e60248201527f536166654d6174683a207375627472616374696f6e206f766572666c6f770000604482015290519081900360640190fd5b5090039056fe4f776e61626c653a206e6577206f776e657220697320746865207a65726f20616464726573734661756365743a206d696e42616c616e6365203c3d206465736972656442616c616e6365a26469706673582212205ca59b8e2e6ccfb250da7242650577b0c27d1f8124aec6c1e8e976d46d2933a264736f6c63430007060033
Age | Block | Fee Address | BC Fee Address | Voting Power | Jailed | Incoming |
---|
Make sure to use the "Vote Down" button for any spammy posts, and the "Vote Up" for interesting conversations.