2

I want to send payment to base account once i receive ethers in my account. How do I achieve that. I saw many of them referring to etherscan.io sends email once you receive a payment. How can I process it further from code?

Unable to comment on How can I get notification from geth when I receive ether?

Hence raising a new question.

  • use etherscan, it is safer and easier. to send a payment you could use MyEtherWallet's node , so you don't need to set your own node for this. This way nobody would try to hack you because nobody would know you are running a money transfer service. Because, to make transfers automatically you would have to keep the password/privatekey hardcoded within the source. – Nulik Dec 15 '17 at 23:46
  • Any ideas how to manage that using Web3py? – Dawid Walas Jul 27 '18 at 13:55
3

I'm using web3j (not web3js) but I'm sure the code is similar. I have this in my code to listen for incoming transactions to my address:

private void initializeWalletTxListener() {

    web3j.transactionObservable().subscribe( tx -> {

        if( credentials.getAddress().equals( tx.getTo() )) {

            Logger.info( "This is my money! -> addr: {}, amt: {}", 
                    credentials.getAddress(), tx.getValue() );
        }
    });
}

It checks all incoming transactions that have been mined to a block and looks to see that the "to" address is the same as my address. If it is, it does something.

2

Maybe a simple contract can solve what you are trying to achieve?

I have written some template for you in Ethfiddle, you can use the IDE to build up and instantly validate more functions to my template https://ethfiddle.com/e4bkTgUdgO

pragma solidity ^0.4.19;

contract AutoPayment{
  // here you declare address you want to route ETH flows to
  address target_address = 0x45fB94ab5E7090A1145D988a1041144c74C66BEc;

  // each time the contract is funded, ETH will route to target_address
  function () payable public {
    target_address.transfer(this.balance);
  }   
}

Deploy a contract on Ethereum network, and ask you respondents to send ETH to the newly created contract address, instead of your account. Any ETH sent this way will automatically be routed to target_address defined in the contract.

Please let me know if you still want an extended solution on top of one provided via the link. I think this can be done with python + some cron scheduling as well.

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.