PatrickAlphaC / fund_me

49 stars 85 forks source link

"send" and "transfer" are only available for objects of type "address payable", not "address" #5

Closed jdecrypted closed 2 years ago

jdecrypted commented 2 years ago

I see the above error while compiling " ``` function withdraw() payable public { msg.sender.transfer(address(this).balance); }


"
However, If I add import "@chainlink/contracts/src/v0.6/vendor/SafeMathChainlink.sol"; it works fine, 
I am not sure this import is helping in rectifying the issue. 
Any pointers will be helpful.
jdecrypted commented 2 years ago

sorry, for previous mention "chainlink/contracts/src/v0.6/vendor/SafeMathChainlink.sol", actually it has no role in compilation.

jdecrypted commented 2 years ago

okay, I figured it out, I had to typecast it.

        address payable addr2 = payable(msg.sender);
        addr2.transfer(address(this).balance);

It worked.