0
pragma solidity 0.4.21;

contract Forwarder {

  address public destinationAddress;
  event LogForwarded(address indexed sender, uint amount);
  event LogFlushed(address indexed sender, uint amount);

  function Forwarder() public {
    destinationAddress = msg.sender;
  }

  function() payable public {
    emit LogForwarded(msg.sender, msg.value);
    destinationAddress.transfer(msg.value);
  }

  function flush() public {
    emit LogFlushed(msg.sender, address(this).balance);
    destinationAddress.transfer(address(this).balance);
  }

}

Please just say the spot by replying HERE1 or HERE2 blah blah as it's on the script above.

for example, my destination address where I want all eth on contract to be forwarded to is 0x7e0fE0Bd87F84906bc19438fb5F932e189Dd127e, where do I put it on the script?

0

The destination address is set based off who is the contract creator based off the constructor:

function Forwarder() public {
  destinationAddress = msg.sender;
}

If you want 0x7e0fE0Bd87F84906bc19438fb5F932e189Dd127e to be the destination address, you just have to make sure that the address you mentioned is the creator of the contract.

You could also opt to replace destinationAddress = msg.sender with a hardcoded address, destinationAddress = 0x7e0fE0Bd87F84906bc19438fb5F932e189Dd127e but you shouldn't need to do that if you know how to launch contracts properly from the desired address.

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.