1
pragma solidity ^0.4.2;
/**
 * Contract that will forward any incoming Ether to its creator
 */
contract Forwarder  {
  // Address to which any funds sent to this contract will be forwarded
  address public destinationAddress;

  /**
   * Create the contract, and set the destination address to that of the creator
   */
  function Forwarder() {
    destinationAddress = msg.sender;
  }

  /**
   * Default function; Gets called when Ether is deposited, and forwards it to the destination address
   */
  function () payable {
       {
          if (!destinationAddress.send(msg.value)) throw; 
      }
}

Let say for example my address where I want eth to be redirected to is 0x104ea4435b2ed36f36dc403b3638d82ec6a21bb7 but I am creating a contract from another address which I want the contract to redirect to address above. Where do I put it on the script?

0

In the constructor instead of setting msg.sender as destinationAddress, use your actual address:

function Forwarder() {
        destinationAddress = 0x104ea4435b2ed36f36dc403b3638d82ec6a21bb7
      }

That should do.

Hope this helps

| improve this answer | |

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.