Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

How to judge whether the address of Yi Tai Fong is an intelligent contract or not?

Shulou Source: shulou.com Published: 2022-06-01 02:22:34 09月25日 Update

This article mainly introduces "how to judge whether the Ethernet Fong address is an intelligent contract". In the daily operation, I believe many people have doubts about how to judge whether the etheric Fong address is an intelligent contract. The editor consulted all kinds of data and sorted out a simple and easy-to-use operation method. I hope it will be helpful for you to answer the doubt of "how to judge whether the etheric Fong address is an intelligent contract". Next, please follow the editor to study!

Use web3.js

The web3.eth.getCode () method returns the hexadecimal string of the code at the specified address, and since there is no code at the normal account address, only the hexadecimal prefix 0x is returned. Using this, we can make judgments, such as:

Var code = web3.eth.getCode ("0xbfb2e296d9cf3e593e79981235aed29ab9984c0f") if (code = '0x') console.log (' ordinary account') else console.log ('contract account') is implemented in solidity

Within the contract, you can use the EVM assembly code to get the code size at the specified address, obviously, the normal account address will return 0:

Contract EzDemo {function isContract (address addr) returns (bool) {uint size; assembly {size: = extcodesize (addr)} return size > 0;} at this point, the study on "how to determine whether the address of Ethernet Square is an intelligent contract" is over, hoping to solve everyone's doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

Tags: Address contract Intelligence Ethernet account Learning General Code method more binary help practical next previous Generation prefix size character string article Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Tech Info Shulou Information Shulou Technology MariaDB Apple