I am wondering if it is possible to cast a contract-reference to an address payable (in order to send to it money) or if it is possible to declare a contract-reference directly payable (with solidity > 0.5.0). So that the function transfer
can be used.
To make the question more clear, I provide here a minimal example:
contract A {
function() payable {
// fallback logic goes here ...
}
}
contract B {
constructor() payable public {
A a = new A();
address payable receiver = address(a); // cast goes here
receiver.transfer(msg.value);
}
}
Concretely, how can I send money to A via transfer?