4

If I send ether from contractB to contractA, then get error "out of gas".

Increase the amount of gas does not help.

In "VM Trace Transaction" http://testnet.etherscan.io/vmtrace?txhash=0x24269877942122ea5e022833e2dbd80f543458be2195ad2df222387cff7f5382 I see, then call "contractA.send(msg.value);" don't send gas to subcontract.

How to make these contracts work?

contract contractA {
    function() {
        for(uint i = 0;i<10; ++i)
            msg.sender.send(msg.value/10);
    }
}

contract contractB
{
    address contractA = 0x2EA16ad451ca2aA32E06f476691D1529cF11BaC7; // TestNet!!!
    function() {
        if (msg.sender != contractA) {
            contractA.send(msg.value);
        }
    }
}
SkyN
  • 175
  • 3

1 Answers1

4

You need to add gas to the transaction by calling msg.sender.call.gas(10000).value(msg.value/10)().

Be Careful: this could be vulnerable to recursive call attacks. In your case it isn't, but just be aware when sending gas to unknown contracts.

Tjaden Hess
  • 37,046
  • 10
  • 91
  • 118