1

I have an Ethereum wallet address (the public key is known by other people). I periodically receive payment on this address (and cannot change it/receive to other address).

I need: When I receive a payment on it, automatically and immediately it sends/forward them to my new wallet address (the private key is known only by me).

Is this possible and how? I am new to programming, kindly inform me on how to begin doing this.

4
  • This is possible from a script running somewhere (e.g. a cron job). It's quite straightforward; come back with detailed questions if you run into trouble.
    – user19510
    Commented Jul 7, 2018 at 17:40
  • help me my eth address was hacked by someone when i sent eth to my account and immediately my eth was sent back to another address How do I solve it Commented Apr 25, 2021 at 20:22
  • I am also new to coding and have a similar question. Can someone help me in getting this work Thanks Commented May 26, 2021 at 18:17
  • did you solve your problem??????
    – Luka
    Commented Jul 8, 2021 at 7:16

2 Answers 2

2

If you are new to programming, i would suggest you to first study javascript and understand how to work with NodeJs by hosting an application on a server such a Amazon Web Services (AWS).

With that, you will then need to set up an Ethereum node either using Geth or Parity on lightmode. After that, you will need to be able to understand this section of the document here to automate the payment by passing in the privateKey: http://web3js.readthedocs.io/en/1.0/web3-eth.html#sendtransaction

What you'll need to do first is to.

  1. Check you public address for balance if any using web3.eth.getBalance
  2. If balance is not the same as the previous amount, then send whatever amount you want to the new address using sendTransaction.
1

If you knew you would want to set this up in advance, you could use a contract as the initial receiving address and give it a fallback function to automatically forward your ETH. Note that this has the downside that sending to such a contract would require the sender to supply more gas than they normally would while making a transfer, which may cause some payments to fail if they don't realise they should do this.

However, it sounds like your address is already decided and shared, and you've used a normal Externally Owned Account rather than a contract. You can do this with a script polling for changes to the balance of your address, and creating a new transaction to send them on each time a significant amount arrives. See @Zinxer's answer for practical suggestions for how you might implement this.

Unfortunately this will require that a continually-running internet-connected computer somewhere has access to the private key of the receiving address, which is not ideal from a security perpective as if someone were to hack that computer they could steal the private key and take both funds in the address at the time, and any funds sent to it subsequently.

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