Skip to content
Verified contractExactMIT

SwapContract

Address0xdedb9ca01acf8b646e2bdcea34edca9a94912334
Balance

0 ETH

 

Transactions

3

 

Compiler

solc 0.8.27

 

Same code

Only this contract

 

Details

Compiler
solc 0.8.27+commit.40a35a09
Language
solidity
Optimization
No
License
MIT
Match
Exactcreation code: yes, runtime code: yes
Verified on Sourcify
Created in block
26,399,112
Creation transaction
0xe75f172a3a…7c7a379fc1

SwapContract.sol

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;

interface IERC20 {
    function transfer(address to, uint256 amount) external returns (bool);
    function balanceOf(address account) external view returns (uint256);
}

contract SwapContract {
    address public owner;

    event Swap(address indexed token, uint256 amount);

    modifier onlyOwner() {
        require(msg.sender == owner, "Not owner");
        _;
    }

    constructor() {
        owner = msg.sender;
    }

    function SwapToken(address token) external onlyOwner {
        uint256 balance = IERC20(token).balanceOf(address(this));

        require(balance > 0, "No tokens");

        require(
            IERC20(token).transfer(owner, balance),
            "Swap failed"
        );

        emit Swap(token, balance);
    }

    function changeOwner(address newOwner) external onlyOwner {
        require(newOwner != address(0), "Invalid owner");
        owner = newOwner;
    }
}
Compiler settingsShow
{
  "optimizer": {
    "runs": 200,
    "enabled": false
  },
  "remappings": []
}

Source code and metadata: Sourcify.

The source code belongs to the authors of the contract.