0

Have code like this:

pragma solidity ^0.4.21;

contract Forwarder {
    address public owner;
    mapping(address => uint256) public stored;

    function Forwarder () public {
        owner = msg.sender;
    }

    function () public payable {
        owner.transfer(msg.value);
    }

    function transfer (address contractAddress) public {
        require (stored[msg.sender] > 0);
        contractAddress.transfer(stored[msg.sender]);       
    }

    function store () public payable {
        stored[msg.sender] += msg.value;
    }
}

But i cannot use "transfer" method if i set contractAddres = 0xSomeContractAddress, but if it will be account address all found will be successfully sent.

What am i doing wrong?(except English skills)

  • How does the contract at 0xSomeContractAddress look like? – lunr Jun 10 '18 at 9:05
  • You should show the cod of the receiver contract, also what error do you get? – Jaime Jun 10 '18 at 9:10
2

It's probably because the receiving contract does not have its "default" function as payable.

You have to include at least this in the receiving contract.

function() payable {
    ...
}
  • Yeah, i know it, but thanks. There was a problem that i can not call payable function of another contract from payable function of mine. – Виктор Козлов Jun 19 '18 at 12:02

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.