Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Address.toPayable() #1771

Closed
nventuro opened this issue May 24, 2019 · 6 comments · Fixed by #1773
Closed

Address.toPayable() #1771

nventuro opened this issue May 24, 2019 · 6 comments · Fixed by #1773
Labels
contracts Smart contract code. good first issue Low hanging fruit for new contributors to get involved!

Comments

@nventuro
Copy link
Contributor

🧐 Motivation
As seen in this StackOverflow question, there's no easy (reasonable) way to convert an address into an address payable. This was confirmed by the Solidity team on gitter. We should provide a simple wrapper for this ugly conversion.

📝 Details
This would simply be a new internal pure function in Address, that takes an address and returns address payable. In order to do the conversion, we must first cast the address type into uint160.

@nventuro nventuro added good first issue Low hanging fruit for new contributors to get involved! contracts Smart contract code. labels May 24, 2019
@Skyge
Copy link
Contributor

Skyge commented May 25, 2019

Yeah, in Solidity 0.5, this is one of the breaking changes, but for some developers including myself, we just use like this address(uint160(_owner)) to make it become address payable, so it is really a good proposal to provide a simple wrapper.

@pokcup
Copy link

pokcup commented May 29, 2019

ใช่ใน Solidity 0.5 นี่เป็นหนึ่งในการเปลี่ยนแปลงที่ไม่หยุดยั้ง แต่สำหรับนักพัฒนาบางคนรวมถึงตัวฉันเองเราแค่ใช้สิ่งนี้address(uint160(_owner))เพื่อทำให้มันกลายเป็นaddress payableจริงดังนั้นจึงเป็นข้อเสนอที่ดีที่จะให้เสื้อคลุมเรียบง่าย

@Skyge
Copy link
Contributor

Skyge commented May 29, 2019

@pokcup It is really hard for me to understand your words, could you please use the English?

@nventuro
Copy link
Contributor Author

@pokcup ยินดีต้อนรับ! Please write in English when communicating over this medium :)

@yopereir
Copy link
Contributor

yopereir commented May 31, 2019

Would the solution be a function like this within Address.sol ?

    //@dev Converts an address to address payable.
    function toPayable(address account) internal pure returns (address payable) {
        return address(uint160(account));
    }

@frangio
Copy link
Contributor

frangio commented May 31, 2019

@RCYP Yes, though @Skyge is already working on this, see #1773.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
contracts Smart contract code. good first issue Low hanging fruit for new contributors to get involved!
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants