如何找出以太坊地址是否是合约? [英] How to find out if an Ethereum address is a contract?

查看:215
本文介绍了如何找出以太坊地址是否是合约?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Solidity中的地址可以是帐户或合同(或其他事物,例如交易)。当我有一个变量x并保存一个地址时,如何测试它是否是合同?

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 contract or not?

(是,我已经阅读过有关类型的章节(在文档中)

(Yes, I've read the chapter on types in the doc)

推荐答案

编辑:自从首次编写此答案以来,可靠性已经发生了变化,@manuel-aráoz具有正确的答案。

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.

这篇关于如何找出以太坊地址是否是合约?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆