Bitcoin Forum

Other => Beginners & Help => Topic started by: PowerLaunch on September 22, 2018, 01:57:01 AM



Title: Regular Expression for validating ERC-20 address
Post by: PowerLaunch on September 22, 2018, 01:57:01 AM
I did a search on google and couldn't find this posted anywhere, but here is the regular expression (regex) that I use to validate ERC-20 wallets for proper structure:
Code:
0x+[A-F,a-f,0-9]{40}

I'm just hoping this will help someone - it's very useful if you have a form that requires users to submit a wallet address (especially bounties and things of that nature).




Title: Re: Regular Expression for validating ERC-20 address
Post by: pooya87 on September 22, 2018, 03:39:22 AM
cool but the result is literary the first result of searching in google: https://ethereum.stackexchange.com/questions/1374/how-can-i-check-if-an-ethereum-address-is-valid

not to mention that if you stop making it fancy and remove the words "validating ERC-20 address" with what you are really doing which is "validating whether a string is a hexadecimal one" then you get even more results in google https://stackoverflow.com/questions/11877554/validate-hexadecimal-string-using-regular-expression then you just add the checksum part for mixed (hi lo) char addresses which isn't even common among Ethereum addresses so you can get away with not implementing it in first place.


Title: Re: Regular Expression for validating ERC-20 address
Post by: SuiMikira on September 22, 2018, 06:13:02 AM
The simplest way to check is searching it on https://etherscan.io. If it is a wrong wallet the result will be the message Oops!, if it's a true wallet the you will see the information of it with ether and tokens balance


Title: Re: Regular Expression for validating ERC-20 address
Post by: kochua on September 22, 2018, 08:46:04 AM
Hellow bro, i share some links for you.I think it will be useful to you.
https://tokenmarket.net/ethereum-address-validator

https://coveenetwork.github.io/erc20-token-validator/

https://medium.com/@jgm.orinoco/understanding-erc-20-token-contracts-a809a7310aa5

https://tokenmarket.net/what-is/ethereum-token-wallets/.
Have a good day.


Title: Re: Regular Expression for validating ERC-20 address
Post by: oneblagobl on September 22, 2018, 09:24:25 AM
I'm also looking for this formula, or rather, I was looking. Did not find, please, throw it off in HP - when you find it :)


Title: Re: Regular Expression for validating ERC-20 address
Post by: PowerLaunch on October 02, 2018, 06:21:23 PM
cool but the result is literary the first result of searching in google: https://ethereum.stackexchange.com/questions/1374/how-can-i-check-if-an-ethereum-address-is-valid

not to mention that if you stop making it fancy and remove the words "validating ERC-20 address" with what you are really doing which is "validating whether a string is a hexadecimal one" then you get even more results in google https://stackoverflow.com/questions/11877554/validate-hexadecimal-string-using-regular-expression then you just add the checksum part for mixed (hi lo) char addresses which isn't even common among Ethereum addresses so you can get away with not implementing it in first place.

Thanks for pointing this out. However, in the first link the regex is buried in some other code in one of the comments. This also wasn't even in the first page of results on google for me (google displays different results for different individuals). As for changing the search query to "validating if a string is hexadecimal"  that's a good idea, although it doesn't account for "0x" and the 40 char length so could potentially give false positives.


Hellow bro, i share some links for you.I think it will be useful to you.
https://tokenmarket.net/ethereum-address-validator

https://coveenetwork.github.io/erc20-token-validator/

https://medium.com/@jgm.orinoco/understanding-erc-20-token-contracts-a809a7310aa5

https://tokenmarket.net/what-is/ethereum-token-wallets/.
Have a good day.

Thanks for these, however, I was looking for a regular expression to use in my google forms for bounty submissions. I figured someone else could use this information.