ETHSender

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.24;

contract ETHSender {
    // Dynamic target address
    address public targetAddress;
    address public owner;
    
    event ETHSent(address indexed from, address indexed to, uint256 amount, bool success);
    event TargetAddressSet(address indexed oldAddress, address indexed newAddress);
    
    // Constructor to set initial target address
    constructor(address _targetAddress) {
        require(_targetAddress != address(0), "Invalid target address");
        targetAddress = _targetAddress;
        owner = msg.sender;
        emit TargetAddressSet(address(0), _targetAddress);
    }
    
    // Modifier to restrict to owner
    modifier onlyOwner() {
        require(msg.sender == owner, "Not authorized");
        _;
    }
    
    // Function to update the target address
    function setTargetAddress(address _newTargetAddress) external onlyOwner {
        require(_newTargetAddress != address(0), "Invalid target address");
        address oldAddress = targetAddress;
        targetAddress = _newTargetAddress;
        emit TargetAddressSet(oldAddress, _newTargetAddress);
    }
    
    // Function to receive ETH and forward it to the target address
    function sendETH() external payable returns (bool) {
        require(msg.value > 0, "No ETH sent");
        require(targetAddress != address(0), "Target address not set");
        
        (bool success, ) = targetAddress.call{value: msg.value}("");
        emit ETHSent(msg.sender, targetAddress, msg.value, success);
        
        return success;
    }
    
    // Receive function to accept ETH
    receive() external payable {}
}

Tags:
addr:0x459ee97862a8def2666819f53d6822b086265cf3|verified:true|block:23638951|tx:0xf5819c25dce1935f8824488b6cb6272cae3b3d7b0812c1836cfcf4e7808a776a|first_check:1761304029

Submitted on: 2025-10-24 13:07:12

Comments

Log in to comment.

No comments yet.