5

Got address from 3rd-party library:

address wallet = rlp[5].toAddress();

And wanna transfer some funds to it:

wallet.transfer(amount);

Got error:

TypeError: Member "transfer" not found or not visible after argument-dependent lookup in address.
        wallet.transfer(amount);
        ^-------------^

And casts not works:

((address payable)(wallet)).transfer(amount);
4

Here is how to cast address to address payable:

address addr = 0x****;
address payable wallet = address(uint160(addr));

And contract cast to address payable:

MyContract addr = MyContract(0x****);
address payable wallet = address(uint160(address(addr)));
  • thank you for this @K06a – wandos Jun 11 at 6:24

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.