I've been trying to create a contract that forwards any ETH it receives to the account that published the contract.
I've tried several variations on this code, including hard-coding the address, removing the flush function, and others. It deploys successfully, but when I send Ether to the contract, it fails to execute with the warning:
Warning! Error encountered during contract execution [Bad jump destination]
I've consulted the documentation, and browser-solidity suggests it should work correctly. What am I missing?
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() { if (!destinationAddress.send(this.balance)) throw; } } Example of a failed transaction.
What am I missing?