There are many possible ways to achieve this. One possible quick and dirty solution is to check if a ERC20 function exists on the contract address by calling the following:
eth.call({to:contractAddress, data:web3.sha3("balanceOf(address)")})
A non-ERC20 will return a 'null'0xhex response whereas an ERC20 will give you a 32byteuint, in this case 0 but if you provide an address in the data then it will give you the actual token balance for that address.
This is not a guaranteed way of determining a contract is ERC20 since other contracts may expose the same function, however it is a quick and easy check. You could add additional calls ontotalSupply()etc. for more confirmation.
Hope this helps!
To know more, Enroll withBlockchain trainingonline today.
Thank You!!
FAQs
You can use a tool or library to call these functions on the target address. Evaluating Return Values: If the function calls succeed and return valid values (e.g., a non-zero balance or a total token supply), it's a strong indication that you're dealing with an ERC20 token contract.
How do I check if my address is ERC-20? ›
The exchange will make it clear what type of chain they are using; however, one easy way to differentiate between these two is by the way the address is structured. An ERC20 Address only starts with '0' and 'x'. For example: 0xbc6e. A TRC20 Address only begins with a capital 'T'.
How to find out if an Ethereum address is a contract? ›
Using code size of the address
Another way you can determine whether a given address is a contract or an externally-owned account (EOA) by checking the code size of the address. If an address is a contract, its code size will be greater than zero, as contracts have bytecode associated with them, whereas EOAs do not.
Can you send ERC-20 tokens to an Ethereum address? ›
ERC-20 tokens are digital assets built on the Ethereum blockchain, following a specific set of standards that allow them to be shared, exchanged, or transferred to any Ethereum address.
What does ERC-20 wallet address look like? ›
An ERC-20 wallet address is a unique alphanumeric string, usually 42 characters long, that identifies your ERC-20 wallet. This address allows others to send any ERC-20 tokens to your wallet. Herewith, the tokens are not kept inside the wallet itself, they exist on the Ethereum blockchain.
How to detect if a contract is ERC20? ›
You can use a tool or library to call these functions on the target address. Evaluating Return Values: If the function calls succeed and return valid values (e.g., a non-zero balance or a total token supply), it's a strong indication that you're dealing with an ERC20 token contract.
How to find a token contract address? ›
On the homepage of MetaMask Extension, under the 'Tokens' tab, click on the token whose contract information you want. Then, click on the vertical three dots menu and select 'View asset in explorer'. This action will take you to the token's contract address on the active network.
How to identify a contract address? ›
The contract address can be found on the home page of the NFT collection or next to a particular NFTs token ID and other metadata. When buying an NFT, always make sure it features the same contract address as other NFTs in the collection.
How do I verify my ethereum contract? ›
If you are the contract owner and would like to verify your contract, kindly follow the steps below:
- Verify and Publish. Under the contract address page, next to the “Token Transfers” tab, you will be able to find the “Contract” tab. ...
- Verify Contract Code. ...
- Confirm Contract Details.
What is Ethereum ERC20 contract address? ›
An Ethereum ERC20 contract address refers to a unique identifier assigned to a smart contract deployed on the Ethereum blockchain that complies with the ERC20 token standard.
Each cryptocurrency, including any ERC-20 tokens we list, have their own deposit addresses. You can only deposit ERC-20 tokens that we have listed. All ERC-20 Tokens on Kraken use a shared address. For example, when generating an Augur (REP) address the same address will be generated for other listed ERC-20 tokens.
How do I get my ERC-20 wallet address? ›
Find your wallet address: Go to the wallet or click on receive button and the alphanumeric wallet address will be revealed there. Copy the address to share it with others: Copy and paste the address to share it with others. Always copy and share your address to ensure that you do not make a mistake.
Can I swap ERC20 token for Ethereum? ›
Erc20 tokens are basically tokens that reside on Ethereum chain. You can convert them to ETH on any centralized exchange.
Are all Ethereum wallets ERC-20? ›
The first thing you need to know is that all Ethereum wallet addresses are compatible with ERC-20 tokens. While this is a given, it is the prerogative of your wallet provider to provide you with permission to access your ERC-20 token balance.
How do I identify a wallet address? ›
A wallet address is a string of letters and numbers from which cryptocurrencies or NFTs can be sent to and from. A wallet address is also known as a Public Key and can be shared with different contacts like an email address.
Is ERC the same as ERC-20? ›
The Ethereum Request for Comment number 20 (ERC20) is an implemented standardization proposal for smart contracts. So, while they are related, they are not the same thing.
How do I get my ERC20 wallet address? ›
Find your wallet address: Go to the wallet or click on receive button and the alphanumeric wallet address will be revealed there. Copy the address to share it with others: Copy and paste the address to share it with others. Always copy and share your address to ensure that you do not make a mistake.
Are ERC20 addresses case sensitive? ›
They're also not case sensitive. This address is a number, even though it also includes alphabetical characters. This is because the hexadecimal (base 16) system used to generate the address doesn't just use numerals, like our ten-digit decimal system.
How does an USDT address look like? ›
A USDT (Tether) wallet address is a unique identifier used to send and receive USDT tokens on the Tether network. An example of a USDT wallet address looks like this: 0x3e4d9c2d7c7b6d3e3cb4cfe4f1b1f2b3ae9d0e6a.