1

how can i change this for older compiler versions like 0.4.24?

(bool success, ) = transaction.to.call{value: transaction.value}(transaction.data);

and if you have time please explain to me the call method parameters here? how is this line of code sending parameters to the call function?! why the value is sent in {} and transaction.data is sent in parenthesis?! and why the success boolean inside parenthesis?! and why there is a comma there?!. this 0.8 compiler is weird to me.

1 Answer 1

1

A direct translation would be

bool success = transaction.to.call.value(transaction.value)(transaction.data);
  • Since solc v0.7 address.call{value: amount}() indicates that amount ether will be sent with the call. Before that you had to use this syntax address.call.value(amount)().

  • transaction.data encodes the function and parameters to be executed. You can pass an empty "" to call the fallback function.

  • Sincd solc v0.5 address.call() returns a tuple (bool, bytes memory). The bool parameters indicates if the call was successful or not, the second value is the output returned by the called function. By leaving out the second parameter it will be ignored (bool success, ).

1
  • thnx a lot brother
    – ali
    Commented Jun 15, 2021 at 9:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.