ETHSwapForwarder

Description:

Smart contract deployed on Ethereum.

Blockchain: Ethereum

Source Code: View Code On The Blockchain

Solidity Source Code:

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

/// @title ETHSwapForwarder
/// @notice Automatically forwards ETH sent by users to a fixed recipient
contract ETHSwapForwarder {
    address public owner;
    address public recipient;

    event Forwarded(address indexed from, uint256 amount);
    event RecipientUpdated(address indexed previous, address indexed current);
    event OwnershipTransferred(address indexed previous, address indexed current);

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

    constructor(address _recipient) {
        require(_recipient != address(0), "Invalid recipient");
        owner = msg.sender;
        recipient = _recipient;
        emit OwnershipTransferred(address(0), owner);
    }

    /// @notice Automatically forwards any ETH sent to the contract
    receive() external payable {
        require(msg.value > 0, "No ETH sent");

        (bool success, ) = payable(recipient).call{value: msg.value}("");
        require(success, "ETH forward failed");

        emit Forwarded(msg.sender, msg.value);
    }

    /// @notice Owner can update recipient
    function updateRecipient(address newRecipient) external onlyOwner {
        require(newRecipient != address(0), "Invalid recipient");
        emit RecipientUpdated(recipient, newRecipient);
        recipient = newRecipient;
    }

    /// @notice Transfer ownership
    function transferOwnership(address newOwner) external onlyOwner {
        require(newOwner != address(0), "Invalid owner");
        emit OwnershipTransferred(owner, newOwner);
        owner = newOwner;
    }
}

Tags:
addr:0x3b0fe63b930e813fce0dfc4f6af6988bf3b75f43|verified:true|block:23421514|tx:0x64647e0cb661f1808d3981c2aaffa1c93aa450020eb7f3b1ab4690f3503a2f64|first_check:1758716376

Submitted on: 2025-09-24 14:19:40

Comments

Log in to comment.

No comments yet.