0

I'm new to Smart Contracts and I'm trying to build a simple Smart Contract, which sends all the ETH to a certain address if the balance gets greater than 0. I hope you can give me an example contract. :)

Best regards

1 Answer 1

1

This will do the job:

// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.7.0 <0.9.0;

contract TestContract {
    address public ethReceiver = <YOUR_RECEIVER_ADDRESS>;

    receive() payable external {
        payable(ethReceiver).transfer(address(this).balance);
    }
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.