I've come to understanding that in order to write a solidity function in the contract that allows me to send money from the contract to some address I have to use something like this:
function transfer(address payable _to, uint _amount) public {
(bool success, ) = _to.call{value: _amount}("");
require(success, "Failed to send Ether");
}
But what is this? First thing: is .call{...}("") even a function at all? Why do I have to put an empty string there? And what's the deal with the curly brackets before the parameter list of the function call?
I've also found a different way to do it, like this:
addr.call{value: msg.value, gas: 5000}(abi.encodeWithSignature("foo(string,uint256)", "call foo", 123));
So, do I need to specify the gas value for the transaction or not? And what's inside the parameter list (that abi.encodeWithSignature(...))?
Also why the definition of the variable success is in brackets? is it the same as doing the following in Python?
# ignoring value_2
value_1, _ = my_function()
Sorry for asking so many question, but I've had a hard time trying to find/understand the solidity documentation.