2

I'm trying to call a contract from another contract. When I use a simple example, like below, it just works fine, no problem, the counter in contract A adds up when I trigger function in contract B:

pragma solidity ^0.4.13;

contract A {
    uint public counter ; 
    function increment(uint add) {
       counter = counter + add;
    }
}

contract B {
    function delegateIncrement(uint add) {
        A(addressA).increment(add) ; 
    }
}

But when I want to incorporate a transfer function, like below, nothing happens. I don't get why. Increased gas etc already.:

pragma solidity ^0.4.13;

contract Betaal{
    address public bedrijf = addresBedrijf;

    function UitBetalen(){
        bedrijf.transfer(this.balance);
    }

    function ()payable{
    }
}

contract Trigger{
    function TriggerBetaling() payable{
        Betaal(addressBetaal).UitBetalen;
    }   
}

When I the "uitbetalen" function directly in the "Betaal"contract, it works just fine, but when I want to trigger it using the "TriggerBetaling" function in the "Trigger" contract, the transaction reaches the Trigger contract just fine and then nothing happens, the uitbetalen function is not triggered. Anyone any idea?

I'm using remix and metamask, but they seem to work just fine.

  • 1
    You forgot parentheses after Betaal(addressBetaal).UitBetalen. Just add () to make a call. – max taldykin Jul 21 '17 at 13:35
  • sometimes the answer can be that simple..........thanks! wasted a beautifull 2 hours staring at my code, hahaha! – Olivier Rikken Jul 21 '17 at 14:45
  • @maxtaldykin pls post as an answer – dcorking Aug 15 '17 at 12:04
1

You forgot parentheses after Betaal(addressBetaal).UitBetalen. Just add () to make a call.

| improve this answer | |

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.