[Ethereum] Why call() function stopped working in solidity 0.5.0

remixsolidity

I am sending ether to another smart contract and calling its fallback function with higher gas as like:

contractAddress.call.value(1 ether).gas(53000)();

It was working in solidity version 0.4.25 but it stopped working in 0.5.0 giving me error:

TypeError: Wrong argument count for function call: 0 arguments given
but expected 1. This function requires a single bytes argument. Use ""
as argument to provide empty calldata.

If I try to add blank argument in call() as it says in the error, then it gives me another error:

TypeError: Member "value" not found or not visible after
argument-dependent lookup in tuple(bool,bytes memory) – did you forget
the "payable" modifier?

I studied the breaking change documentation but that still could not find the solution.
Any help would be appreciated 🙂

Best Answer

Make sure contractAddress is of type address payable. And yes, you'll need to provide an argument. E.g.:

address payable contractAddress = ...;
contractAddress.call.value(1 ether).gas(53000)("");
Related Topic