4

Hey guys I'm curious about an idea i was having earlier. I am a total beginner so bare with me ;) I want to create a contract that basically just sends ether to another contract. BUT the user should be able to input another address. This address and the ether will then be sent to another contract.

So in example User B sends a specific amount of Ether to Contract1. He also inputs another address he owns. Then, Contract1 sends the whole amount of Ether to Contract2, exporting the input address as well. I only want to get this far for now.

Is this even possible? And if so, can somebody write some example code? I can't find an address input option in the solidity documentation.

I'm not familiar with solidity so I'm just 'learning by doing' as they say.. :)

Thanks for your help!

  • So B(address1)=>contact1=>contract2=>B(adress2) a kind of proxy!! is it right? – Badr Bellaj Oct 10 '16 at 16:01
  • Yeah a proxy is exactly what i'm trying to achieve. The ultimate goal would be the following: User A sends ether to Contract1 including multiple adresses. The contract divides the received ether randomly and sends them to the input addresses. Preferably using multiple other contracts, so the ether get spread even further. If many people used that contract ethereum would be almost completely anonymous, even on exchanges. – user4613 Oct 10 '16 at 17:51
2

How about something like that:

pragma solidity ^0.4.2;

contract Receiver {
    function receive(address benefactor) payable
        returns (bool) {
        // Receives msg.value from msg.sender, in your case ForwardExample
        // But understands benefactor is the one who "paid".
        return true;
    }
}

contract ForwardExample {
    // Keep the target contract in, instead of passing it as a parameter
    // To forward function.
    Receiver receiver;

    function ForwardExample(address receiverAddr) {
        receiver = Receiver(receiverAddr);
    }

    function forward(address myOtherAddress) payable
        returns (bool) {
        // Pass on the whole ether received.
        bool successful = receiver.receive.value(msg.value)(myOtherAddress);
        if (!successful) throw;
        return true;
    }
}
  • Some questions: First: Did you just write that down or have you written a similar contract before? Second: How did you start to program with solidity? Are you doing it for a living? I'm just a student but i really want to get into contract developing. I have tons of ideas but no knowledge (besides Python, HTML and JavaScript) to further work on them. Any tips for a beginner? – user4613 Oct 10 '16 at 17:59
  • I quickly wrote that down in "Browser Solidity" and, although I feel confident, you will be better off writing tests ;). And yes, I do that for a living. Shameless plug for academy.b9lab.com here... – Xavier Leprêtre B9lab Oct 10 '16 at 18:06
  • I would like to test your services one day. Maybe next year. :-) – soc1c Oct 22 '16 at 20:17

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.