How to find out if an Ethereum address is a contract?

后端 未结 6 841
谎友^
谎友^ 2020-12-24 13:31

An address in Solidity can be an account or a contract (or other things, such as a transaction). When I have a variable x, holding an address, how can I test if it is a cont

6条回答
  •  滥情空心
    2020-12-24 14:08

    Edit: Solidity has changed since this answer was first written, @manuel-aráoz has the correct answer.

    There is no way in solidity to check if an address is a contract. One of the goals of Ethereum is for humans and smart contracts to both be treated equally. This leads into a future where smart contracts interact seamlessly with humans and other contracts. It might change in the future , but for now an arbitrary address is ambiguous.

提交回复
热议问题