I'm not very familiar with cryptocurrency, but i need somehow validate ethereum wallet address. I've found a way, but it also accept token contract address. So is there a way to differ them, and only allow wallet addresses and not contract address

2 Answers 2


If you use web3 you can use this way

web3_instance.eth.getCode(address).then(function (code) {
    if (code === "0x") {
        // this address is account
  • Unfortunately i can't use web3. What does getCode do? Can i implement it by myself using c++ for exampe?
    – Zimme
    Nov 29, 2021 at 16:41
  • This data is only available on network and you must use their library to fetch the data binary of each address if it is a contract then it has data more than 0x if is not it has 0x Nov 29, 2021 at 18:36

I'm not quite sure if there is web3 library for C++, but another way you can achieve this by using the Etherscan API. You need to register and obtain your api key and then you will be able to use the Etherscan API with certain limits.

This is how you are going to build your GET request:


Where <YOUR_ADDRESS> is the address you are about to validate and <YOUR_API_KEY> value is the key which you are going to receive from the Etherscan API.

The two main responses which you're going to receive back from the request are:

Address which is not a smart contract - {"status":"0","message":"NOTOK","result":"Contract source code not verified"}

And address which is a smart contract - {"status": "1","message": "OK","result": <ABI_DEFENITION_OF_THE_CONTRACT>}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.