Hi there!
I'm having some trouble to understand why two very similar and simple smart contracts are behaving differently. Both of them are using .call.gas(10000000).value(msg.value)(""), but one of them run out of gas when the target contract triggers a transfer function.
You can check the context, link for transactions on Rinkeby and images on this blog post:
But basically, I'm using the following contracts:
// SPDX-License-Identifier: None
pragma solidity 0.6.0;
contract SenderWithRequire {
function send(address payable receiver) public payable {
(bool success,) = receiver.call.gas(10000000).value(msg.value)("");
require(success, "Failed to send value!");
}
}
contract SenderWithEmit {
event Debug(bool success);
function send(address payable receiver) public payable {
(bool success,) = receiver.call.gas(10000000).value(msg.value)("");
emit Debug(success);
}
}
contract Sender {
function send(address payable receiver) public payable {
receiver.call.gas(10000000).value(msg.value)("");
}
}
contract Receiver {
bool public hasReceived;
receive() external payable {
hasReceived = true;
payable(address(0)).transfer(msg.value);
}
}
Both SenderWithEmit and SenderWithRequire work fine, but Sender fails.
I'm mostly using Remix with default gas limit 3000000.
Thanks in advance!