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;
}
}
Digamos, por ejemplo, que mi dirección a la que quiero que se redirija eth es 0x104ea4435b2ed36f36dc403b3638d82ec6a21bb7 pero estoy creando un contrato desde otra dirección que quiero que el contrato redirija a la dirección anterior. ¿Dónde lo pongo en el guión?
En el constructor, en lugar de configurar msg.sender como destinationAddress
, use su dirección real:
function Forwarder() {
destinationAddress = 0x104ea4435b2ed36f36dc403b3638d82ec6a21bb7
}
Eso debería hacer.
Espero que esto ayude