1

i can't understand this Explicit conversions to and from address are permitted for integers, integer literals, contact types and bytes20. However, Solidity prevents the conversions of address payable(x).

The address(x) can be converted to address payable in cases when x is of integer, fixed bytes type, or a literal or a contract that has a payable fallback function. When x is a contract without the payable fallback function, the address(x) is of type address.

0

It is just an opinion but you have some reason

Given this variables:

address addressVal;
uint160 uint160Val;
bytes20 bytes20Valu;
address payable payableVal;

It will allow some conversion between address and payable

payableVal = address(uint160Val);
payableVal = address(bytes20Val);

And it will fail with the most obvious

payableVal = address(addressVal);
payableVal = addressVal;

(My opinion here is that all of the above should fail)

Fortunately it was introduced with solc 0.6 casting to payable that should work in all cases.

payableVal = payable(uint160Val);
payableVal = payable(bytes20Val);
payableVal = payable(addressVal);
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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