Author

Topic: Regular Expression for validating ERC-20 address (Read 208 times)

copper member
Activity: 50
Merit: 0
www.PowerLaunch.io
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.



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.
jr. member
Activity: 378
Merit: 1
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 Smiley
member
Activity: 364
Merit: 10
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
legendary
Activity: 3472
Merit: 10611
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.
copper member
Activity: 50
Merit: 0
www.PowerLaunch.io
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).


Jump to: