<- Articles
Check whether an EVM address is a contract address or wallet address

First of all, you can use the handy tool here

Using code:

You can first check if the given string is a valid EVM address by using isAddress

import { isAddress } from "thirdweb/utils"; const evmAddressToCheck = "0x..."; const isValidEvmAddress = isAddress(evmAddressToCheck); // If isValidAddress === false then the given string is invalid. // It is NEITHER a contract address or wallet address

If evmAddressToCheck is a valid EVM address:

import { getBytecode, getContract } from "thirdweb/contract"; import { ethereum } from "thirdweb/chains"; import { createThirdwebClient } from "thirdweb"; const evmAddressToCheck = "0x..."; const chainOfYourChoice = ethereum; // we use ethereum as the chain in this example export const client = createThirdwebClient({ clientId: "your-client-id", }); const contract = getContract({ address: evmAddressToCheck, chain: chainOfYourChoice, client: client, }); ... const bytecode = await getByteCode(contract); console.log(bytecode); // either "0x" or "0x......abcxyz....." const isWalletAddress = bytecode === "0x"; const isContractAddress = bytecode !== "0x";