Address Contract Verified
Address
0x38AC0359D7B0ed6e2bafB20Dd06900B9EB157d52
Balance
0 ETH
Nonce
1
Code Size
2529 bytes
Creator
0xD840B263...D513 at tx 0xd4ed347e...dd0544
Indexed Transactions
0
Contract Bytecode
2529 bytes
0x6080604052600436106100c2575f3560e01c80638da5cb5b1161007c578063b24c72f611610057578063b24c72f6146101e3578063bbabeb0714610216578063dbf09d6614610235578063f2fde38b1461024a575f80fd5b80638da5cb5b1461018c57806391b7f5ed146101bc578063a6f2ae3a146101db575f80fd5b806304138e6b146100d75780633f4ba83a146101095780635c975abb1461011d578063690d832014610145578063715018a6146101645780638456cb5914610178575f80fd5b366100d3576100d13334610269565b005b5f80fd5b3480156100e2575f80fd5b506100f66100f13660046108bc565b61049e565b6040519081526020015b60405180910390f35b348015610114575f80fd5b506100d16104c5565b348015610128575f80fd5b505f54600160a01b900460ff166040519015158152602001610100565b348015610150575f80fd5b506100d161015f3660046108e7565b6104d7565b34801561016f575f80fd5b506100d161054e565b348015610183575f80fd5b506100d161055f565b348015610197575f80fd5b505f546001600160a01b03165b6040516001600160a01b039091168152602001610100565b3480156101c7575f80fd5b506100d16101d63660046108bc565b61056f565b6100d16105f4565b3480156101ee575f80fd5b506101a47f000000000000000000000000d0b86b79ae4b8d7bb88b37ebe228ce343d79794e81565b348015610221575f80fd5b506100d1610230366004610909565b610617565b348015610240575f80fd5b506100f660025481565b348015610255575f80fd5b506100d16102643660046108e7565b6106f1565b5f81116102a65760405162461bcd60e51b81526020600482015260066024820152650dcde408aa8960d31b60448201526064015b60405180910390fd5b5f6102b08261049e565b6040516370a0823160e01b81523060048201529091505f906001600160a01b037f000000000000000000000000d0b86b79ae4b8d7bb88b37ebe228ce343d79794e16906370a0823190602401602060405180830381865afa158015610317573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061033b9190610933565b9050818110156103815760405162461bcd60e51b81526020600482015260116024820152700696e73756666696369656e7420474c495607c1b604482015260640161029d565b60405163a9059cbb60e01b81526001600160a01b038581166004830152602482018490527f000000000000000000000000d0b86b79ae4b8d7bb88b37ebe228ce343d79794e169063a9059cbb906044016020604051808303815f875af11580156103ed573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610411919061094a565b6104545760405162461bcd60e51b815260206004820152601460248201527311d31254081d1c985b9cd9995c8819985a5b195960621b604482015260640161029d565b60408051848152602081018490526001600160a01b038616917fa9a40dec7a304e5915d11358b968c1e8d365992abf20f82285d1df1b30c8e24c910160405180910390a250505050565b6002545f906104b583670de0b6b3a7640000610969565b6104bf919061098c565b92915050565b6104cd61072e565b6104d561075a565b565b6104df61072e565b47806105165760405162461bcd60e51b81526020600482015260066024820152650dcde408aa8960d31b604482015260640161029d565b6040516001600160a01b0383169082156108fc029083905f818181858888f19350505050158015610549573d5f803e3d5ffd5b505050565b61055661072e565b6104d55f6107ae565b61056761072e565b6104d56107fd565b61057761072e565b5f81116105b35760405162461bcd60e51b815260206004820152600a6024820152697072696365207a65726f60b01b604482015260640161029d565b60025460408051918252602082018390527f945c1c4e99aa89f648fbfe3df471b916f719e16d960fcec0737d4d56bd696838910160405180910390a1600255565b6105fc61083f565b610604610869565b61060e3334610269565b6104d560018055565b61061f61072e565b60405163a9059cbb60e01b81526001600160a01b038381166004830152602482018390527f000000000000000000000000d0b86b79ae4b8d7bb88b37ebe228ce343d79794e169063a9059cbb906044016020604051808303815f875af115801561068b573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906106af919061094a565b6106ed5760405162461bcd60e51b815260206004820152600f60248201526e1dda5d1a191c985dc819985a5b1959608a1b604482015260640161029d565b5050565b6106f961072e565b6001600160a01b03811661072257604051631e4fbdf760e01b81525f600482015260240161029d565b61072b816107ae565b50565b5f546001600160a01b031633146104d55760405163118cdaa760e01b815233600482015260240161029d565b610762610893565b5f805460ff60a01b191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b6040516001600160a01b03909116815260200160405180910390a1565b5f80546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b61080561083f565b5f805460ff60a01b1916600160a01b1790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a2586107913390565b5f54600160a01b900460ff16156104d55760405163d93c066560e01b815260040160405180910390fd5b60026001540361088c57604051633ee5aeb560e01b815260040160405180910390fd5b6002600155565b5f54600160a01b900460ff166104d557604051638dfc202b60e01b815260040160405180910390fd5b5f602082840312156108cc575f80fd5b5035919050565b6001600160a01b038116811461072b575f80fd5b5f602082840312156108f7575f80fd5b8135610902816108d3565b9392505050565b5f806040838503121561091a575f80fd5b8235610925816108d3565b946020939093013593505050565b5f60208284031215610943575f80fd5b5051919050565b5f6020828403121561095a575f80fd5b81518015158114610902575f80fd5b80820281158282048414176104bf57634e487b7160e01b5f52601160045260245ffd5b5f826109a657634e487b7160e01b5f52601260045260245ffd5b50049056fea2646970667358221220254eaa95b3ebb1a40674faec8c1015728f91f7ed1056c101548879c49094506364736f6c63430008140033
Verified Source Code Full Match
Compiler: v0.8.20+commit.a1b79de6
EVM: shanghai
Optimization: Yes (200 runs)
GLIPSale.sol 64 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
import {ReentrancyGuard} from "@openzeppelin/contracts/utils/ReentrancyGuard.sol";
import {Pausable} from "@openzeppelin/contracts/utils/Pausable.sol";
import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol";
import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
/**
* @title GLIPSale
* @notice ETH -> GLIP fixed-price sale contract (prefunded).
*/
contract GLIPSale is Ownable, Pausable, ReentrancyGuard {
IERC20 public immutable glip;
uint256 public priceWeiPerToken; // price for 1 GLIP (18 decimals) in wei
event Bought(address indexed buyer, uint256 ethIn, uint256 glipOut);
event PriceUpdated(uint256 oldPrice, uint256 newPrice);
constructor(address _glip, uint256 _priceWeiPerToken) Ownable(msg.sender) {
require(_glip != address(0), "GLIP addr zero");
require(_priceWeiPerToken > 0, "price zero");
glip = IERC20(_glip);
priceWeiPerToken = _priceWeiPerToken;
}
function calcTokensForEth(uint256 ethWei) public view returns (uint256) {
return (ethWei * 1e18) / priceWeiPerToken;
}
receive() external payable { _buy(msg.sender, msg.value); }
function buy() external payable whenNotPaused nonReentrant {
_buy(msg.sender, msg.value);
}
function _buy(address buyer, uint256 ethIn) internal {
require(ethIn > 0, "no ETH");
uint256 glipOut = calcTokensForEth(ethIn);
uint256 bal = glip.balanceOf(address(this));
require(bal >= glipOut, "insufficient GLIP");
require(glip.transfer(buyer, glipOut), "GLIP transfer failed");
emit Bought(buyer, ethIn, glipOut);
}
function setPrice(uint256 newPrice) external onlyOwner {
require(newPrice > 0, "price zero");
emit PriceUpdated(priceWeiPerToken, newPrice);
priceWeiPerToken = newPrice;
}
function withdrawETH(address payable to) external onlyOwner {
uint256 bal = address(this).balance;
require(bal > 0, "no ETH");
to.transfer(bal);
}
function withdrawGLIP(address to, uint256 amount) external onlyOwner {
require(glip.transfer(to, amount), "withdraw failed");
}
function pause() external onlyOwner { _pause(); }
function unpause() external onlyOwner { _unpause(); }
}
ReentrancyGuard.sol 84 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/ReentrancyGuard.sol)
pragma solidity ^0.8.20;
/**
* @dev Contract module that helps prevent reentrant calls to a function.
*
* Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier
* available, which can be applied to functions to make sure there are no nested
* (reentrant) calls to them.
*
* Note that because there is a single `nonReentrant` guard, functions marked as
* `nonReentrant` may not call one another. This can be worked around by making
* those functions `private`, and then adding `external` `nonReentrant` entry
* points to them.
*
* TIP: If you would like to learn more about reentrancy and alternative ways
* to protect against it, check out our blog post
* https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].
*/
abstract contract ReentrancyGuard {
// Booleans are more expensive than uint256 or any type that takes up a full
// word because each write operation emits an extra SLOAD to first read the
// slot's contents, replace the bits taken up by the boolean, and then write
// back. This is the compiler's defense against contract upgrades and
// pointer aliasing, and it cannot be disabled.
// The values being non-zero value makes deployment a bit more expensive,
// but in exchange the refund on every call to nonReentrant will be lower in
// amount. Since refunds are capped to a percentage of the total
// transaction's gas, it is best to keep them low in cases like this one, to
// increase the likelihood of the full refund coming into effect.
uint256 private constant NOT_ENTERED = 1;
uint256 private constant ENTERED = 2;
uint256 private _status;
/**
* @dev Unauthorized reentrant call.
*/
error ReentrancyGuardReentrantCall();
constructor() {
_status = NOT_ENTERED;
}
/**
* @dev Prevents a contract from calling itself, directly or indirectly.
* Calling a `nonReentrant` function from another `nonReentrant`
* function is not supported. It is possible to prevent this from happening
* by making the `nonReentrant` function external, and making it call a
* `private` function that does the actual work.
*/
modifier nonReentrant() {
_nonReentrantBefore();
_;
_nonReentrantAfter();
}
function _nonReentrantBefore() private {
// On the first call to nonReentrant, _status will be NOT_ENTERED
if (_status == ENTERED) {
revert ReentrancyGuardReentrantCall();
}
// Any calls to nonReentrant after this point will fail
_status = ENTERED;
}
function _nonReentrantAfter() private {
// By storing the original value once again, a refund is triggered (see
// https://eips.ethereum.org/EIPS/eip-2200)
_status = NOT_ENTERED;
}
/**
* @dev Returns true if the reentrancy guard is currently set to "entered", which indicates there is a
* `nonReentrant` function in the call stack.
*/
function _reentrancyGuardEntered() internal view returns (bool) {
return _status == ENTERED;
}
}
Pausable.sol 119 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/Pausable.sol)
pragma solidity ^0.8.20;
import {Context} from "../utils/Context.sol";
/**
* @dev Contract module which allows children to implement an emergency stop
* mechanism that can be triggered by an authorized account.
*
* This module is used through inheritance. It will make available the
* modifiers `whenNotPaused` and `whenPaused`, which can be applied to
* the functions of your contract. Note that they will not be pausable by
* simply including this module, only once the modifiers are put in place.
*/
abstract contract Pausable is Context {
bool private _paused;
/**
* @dev Emitted when the pause is triggered by `account`.
*/
event Paused(address account);
/**
* @dev Emitted when the pause is lifted by `account`.
*/
event Unpaused(address account);
/**
* @dev The operation failed because the contract is paused.
*/
error EnforcedPause();
/**
* @dev The operation failed because the contract is not paused.
*/
error ExpectedPause();
/**
* @dev Initializes the contract in unpaused state.
*/
constructor() {
_paused = false;
}
/**
* @dev Modifier to make a function callable only when the contract is not paused.
*
* Requirements:
*
* - The contract must not be paused.
*/
modifier whenNotPaused() {
_requireNotPaused();
_;
}
/**
* @dev Modifier to make a function callable only when the contract is paused.
*
* Requirements:
*
* - The contract must be paused.
*/
modifier whenPaused() {
_requirePaused();
_;
}
/**
* @dev Returns true if the contract is paused, and false otherwise.
*/
function paused() public view virtual returns (bool) {
return _paused;
}
/**
* @dev Throws if the contract is paused.
*/
function _requireNotPaused() internal view virtual {
if (paused()) {
revert EnforcedPause();
}
}
/**
* @dev Throws if the contract is not paused.
*/
function _requirePaused() internal view virtual {
if (!paused()) {
revert ExpectedPause();
}
}
/**
* @dev Triggers stopped state.
*
* Requirements:
*
* - The contract must not be paused.
*/
function _pause() internal virtual whenNotPaused {
_paused = true;
emit Paused(_msgSender());
}
/**
* @dev Returns to normal state.
*
* Requirements:
*
* - The contract must be paused.
*/
function _unpause() internal virtual whenPaused {
_paused = false;
emit Unpaused(_msgSender());
}
}
Ownable.sol 100 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable.sol)
pragma solidity ^0.8.20;
import {Context} from "../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.
*
* The initial owner is set to the address provided by the deployer. 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;
/**
* @dev The caller account is not authorized to perform an operation.
*/
error OwnableUnauthorizedAccount(address account);
/**
* @dev The owner is not a valid owner account. (eg. `address(0)`)
*/
error OwnableInvalidOwner(address owner);
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the address provided by the deployer as the initial owner.
*/
constructor(address initialOwner) {
if (initialOwner == address(0)) {
revert OwnableInvalidOwner(address(0));
}
_transferOwnership(initialOwner);
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
_checkOwner();
_;
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view virtual returns (address) {
return _owner;
}
/**
* @dev Throws if the sender is not the owner.
*/
function _checkOwner() internal view virtual {
if (owner() != _msgSender()) {
revert OwnableUnauthorizedAccount(_msgSender());
}
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby disabling any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
_transferOwnership(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 {
if (newOwner == address(0)) {
revert OwnableInvalidOwner(address(0));
}
_transferOwnership(newOwner);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Internal function without access restriction.
*/
function _transferOwnership(address newOwner) internal virtual {
address oldOwner = _owner;
_owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
}
IERC20.sol 79 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/IERC20.sol)
pragma solidity ^0.8.20;
/**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/
interface IERC20 {
/**
* @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 Returns the value of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the value of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves a `value` amount of tokens from the caller's account to `to`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address to, uint256 value) 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 a `value` amount of tokens 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 value) external returns (bool);
/**
* @dev Moves a `value` amount of tokens from `from` to `to` using the
* allowance mechanism. `value` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address from, address to, uint256 value) external returns (bool);
}
Context.sol 28 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)
pragma solidity ^0.8.20;
/**
* @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 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) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
function _contextSuffixLength() internal view virtual returns (uint256) {
return 0;
}
}
Read Contract
calcTokensForEth 0x04138e6b → uint256
glip 0xb24c72f6 → address
owner 0x8da5cb5b → address
paused 0x5c975abb → bool
priceWeiPerToken 0xdbf09d66 → uint256
Write Contract 8 functions
These functions modify contract state and require a wallet transaction to execute.
buy 0xa6f2ae3a
No parameters
pause 0x8456cb59
No parameters
renounceOwnership 0x715018a6
No parameters
setPrice 0x91b7f5ed
uint256 newPrice
transferOwnership 0xf2fde38b
address newOwner
unpause 0x3f4ba83a
No parameters
withdrawETH 0x690d8320
address to
withdrawGLIP 0xbbabeb07
address to
uint256 amount
Recent Transactions
No transactions found for this address