What is the difference between call and transfer method?

Hello moralis people

The recommended way is to use call to send ethers to the contracts but the transfer function has a re-entry control, at least that’s what they say here, why do they recommend the first one?

 (bool success, ) = msg.sender.call{value: _balance}("");
            require(success, "Error");
 payable(msg.sender).transfer(_balance);

If it is safer to use transfer, why do you recommend the first one?

transfer -> the receiving smart contract should have a fallback function defined or else the transfer call will throw an error. There is a gas limit of 2300 gas, which is enough to complete the transfer operation. It is hardcoded to prevent reentrancy attacks.

if something changes in the future in the EVM with the gas price, then that transfer may fail with a gas limit of 2300

you can prevent reentrancy attacks in other ways too

So far I have never missed more gas to make transfers between contracts.using transfer function.

But now I understand your recommendation.

I think to avoid re-entries as you rightly say better to use other methods, such as always updating the contract status BEFORE sending anything to anyone or security modifiers.