Skip to content

Contracts<->address explicit conversions #643

@Jds-23

Description

@Jds-23

Describe the feature

  • Contracts can be explicitly converted to address using address(x).
  • Explicit conversion to an address payable is only possible if the contract has a receive or payable fallback function

For address to contract

  • Unlike contract-to-address conversion, there's no restriction requiring the contract to have a receive or payable fallback function to convert from address to contract type. Simply MyContract c = MyContract(addressValue)

https://docs.soliditylang.org/en/latest/types.html#address
http://docs.soliditylang.org/en/latest/types.html#contract-types

Additional context

No response

Metadata

Metadata

Assignees

Labels

A-semaArea: semantic analysisC-enhancementCategory: an issue proposing an enhancement or a PR with one

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions