Skip to content
Verified contractPartialMIT

SWAP

Address0xad532d86e45745f1b122dca89ba3d8cc85d70ec9
Balance

0 ETH

 

Transactions

19

 

Compiler

solc 0.8.17

 

Same code

399 more contracts

 

Details

Compiler
solc 0.8.17+commit.8df45f5f
Language
solidity
Optimization
No
EVM version
london
License
MIT
Match
Partialcreation code: yes, runtime code: yes
Verified on Sourcify
Created in block
19,693,017
Creation transaction
0xc058366072…0e9077acde
Main copy (most transactions)
0x56d6c740…81950dac

SWAP.sol

// 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");
    }  
}
Compiler settingsShow
{
  "metadata": {
    "bytecodeHash": "ipfs"
  },
  "libraries": {},
  "optimizer": {
    "runs": 200,
    "enabled": false
  },
  "evmVersion": "london",
  "remappings": []
}

Source code and metadata: Sourcify.

The source code belongs to the authors of the contract.