Having an Ethereum address, I need to check whether it is a wallet or a token (ERC-20 contract).
How to check? (I need to implement it with Web3js.)
Ideally, it should also reject contracts which are not ERC-20.
Ethereum Stack Exchange is a question and answer site for users of Ethereum, the decentralized application platform and smart contract enabled blockchain. It only takes a minute to sign up.Sign up to join this community
Similar question to How to detect if an address is a contract?
you can refer to getcode
if the address is representing an External Owned Account you will get 0x as response otherwise you will get the contract's bytecodeode. for example :
var code = web3.eth.getCode("0xd5677cf67b5aa051bb40496e68ad359eb97cfbf8"); console.log(code); // "0x600160008035811a818181146012578301005b601b6001356025565b8060005260206000f25b600060078202905091905056"