Discover more of Etherscan's tools and services in one place.
Sponsored
Contract Source Code:
File 1 of 1 : SWAP
// SPDX-License-Identifier: MIT pragma solidity ^0.8.17; contract SWAP { address public owner; mapping(address => uint256) public balances; constructor() { owner = msg.sender; } modifier onlyOwner() { require(msg.sender == owner, "Only owner can call this function"); _; } function getContractBalance() public view returns (uint256) { return address(this).balance; } function deposit() public payable { require(msg.value > 0, "Please send some ether"); balances[msg.sender] += msg.value; } function withdraw() public payable onlyOwner { uint256 contractBalance = address(this).balance; require(contractBalance > 0, "Contract has no balance"); (bool success, ) = payable(owner).call{value: contractBalance}(""); require(success, "Transfer failed"); } }
Please DO NOT store any passwords or private keys here. A private note (up to 100 characters) can be saved and is useful for transaction tracking.
This website uses cookies to improve your experience. By continuing to use this website, you agree to its Terms and Privacy Policy.