0

contract Forwarder {
    address constant private receiver = 123456;

    function() public payable {
        // Forward the received ether to receiver, as well as some gas,
        // which the receiver can use to run code
        // If something goes wrong, the ether is sent back
        require(receiver.call.gas(gasleft() - 2000).value(msg.value)());
        receiver.send(receiver(this).balance);
    }
}

From the Remix complier, I would want to deploy this on the main network and then connect my metamask wallet to this contract so that my transactions would be automated!

Beginner in smart contracts would love to take this opportunity to learn. I apologise for any inconvenience caused.

1
  • The contract doesn't compile. I'm guessing that your intention is to make the metamask address to act as a forwarder, unfortunately that is not possible with solidity.
    – Ismael
    Feb 25, 2022 at 6:22

1 Answer 1

0

If you want to be the receiver, than you should make receiver an immutable and not a constant so you will be able to set it in constructor to your address. In Remix when you deploy the contract in the arguments you can specify the address that you want the receiver to be. The return result of the constructor is the address of the new contract.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.