0

I have more than one ETH wallet. I want to automatically combine these wallets into one wallet. For example, when I get an ETH in wallet 0x1, I want it to automatically transfer it to wallet 0x2. Can I do this with a smart contract? Or how can I do it? Can you help me?

1

You can use a simple contract with a payable fallback function for this. For example:

pragma solidity 0.7.0;

contract Forwarder {
  address payable owner;
    
  constructor (address payable _owner)  {
    owner = _owner;
  }
  
  fallback () external payable {
    owner.transfer(msg.value);
  }
}

Every time ETH is sent to the contract, the fallback function is called, which forwards the ETH (msg.value) to owner.

| improve this answer | |
  • Thank you but that's not what I want. I want it transferred when ETH comes to my A wallet, not a contract. – wexweys Aug 12 at 17:13
  • You asked "Can I do this with a smart contract?", if you don't want to use a smart contract, you'll have to set up some kind of system that checks for incoming transactions, and automatically sends a new transaction. You can't pull ETH from an address with a smart contract. – Morten Aug 12 at 20:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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