When sending some ether to the Proxy contract (payable method addBalance) and forwarding it to Token contract I expect the ether balance of Token contract to increase with the ether amount. However when testing locally the Ether amount is instead added to the Proxy balance. So it seems that the addBalance method of Token contract isn't called. Can somebody explain why this is?

contract Proxy {
    address public owner;

    constructor() {
        owner = msg.sender;

    function addBalance(address _address) public payable {
        console.log('Proxy.addBalance (msg.sender): ', msg.sender);
        console.log('Proxy.addBalance (_address): ', _address);
        console.log('Proxy.addBalance (msg.value): ', msg.value);

        Token(payable(_address)).addBalance{value: msg.value};
  • That's not really possible. Transactions either complete fully or revert completely. So eihter all of the code is executed, or all of the execution is reverted. So the problem must be somewhere else. Commented Sep 12, 2021 at 6:56
  • @LauriPeltonen thanks for your comments. I fully do understand what you are saying and that makes total sense as well. Maybe its my local dev. environment (using local hardhat node) that is the issue. Just did another test and I am seeing only logging which is in the addBalance method of the proxy. The console.log statement in the Token contract is not there. And I am only seeing the balance of the Proxy being increased.
    – martijn
    Commented Sep 12, 2021 at 9:47
  • Probably the problem is that this code Token(payable(_address)).addBalance{value: msg.value}; doesn't do anything. It is not calling a function it is missing the () to call it. It should be a solidity syntax error.
    – Ismael
    Commented Sep 12, 2021 at 18:20
  • @Ismael you are correct, issue solved. After adding the () I see that the balance of the token contract is increased with the Ether that is send to the proxy contract. Thanks for your help!! Without the () the code compiles fine and no warnings are given.
    – martijn
    Commented Sep 13, 2021 at 9:35

1 Answer 1


@Ismael solved the issue. The addBalance function of the Token contract wasn't called as the () was missing. Adding those solved my issue. So the way to do it is Token(payable(_address)).addBalance{value: msg.value}();

  • Great! It would be better if you include the fixed function call.
    – Ismael
    Commented Sep 13, 2021 at 14:00

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.