Bitcoin Forum
April 19, 2024, 04:09:23 AM *
News: Latest Bitcoin Core release: 26.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Regular Expression for validating ERC-20 address  (Read 187 times)
PowerLaunch (OP)
Copper Member
Newbie
*
Offline Offline

Activity: 50
Merit: 0

www.PowerLaunch.io


View Profile WWW
September 22, 2018, 01:57:01 AM
 #1

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).



"I'm sure that in 20 years there will either be very large transaction volume or no volume." -- Satoshi
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
1713499763
Hero Member
*
Offline Offline

Posts: 1713499763

View Profile Personal Message (Offline)

Ignore
1713499763
Reply with quote  #2

1713499763
Report to moderator
1713499763
Hero Member
*
Offline Offline

Posts: 1713499763

View Profile Personal Message (Offline)

Ignore
1713499763
Reply with quote  #2

1713499763
Report to moderator
pooya87
Legendary
*
Offline Offline

Activity: 3430
Merit: 10489



View Profile
September 22, 2018, 03:39:22 AM
Merited by BQ (1)
 #2

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.

.
.BLACKJACK ♠ FUN.
█████████
██████████████
████████████
█████████████████
████████████████▄▄
░█████████████▀░▀▀
██████████████████
░██████████████
████████████████
░██████████████
████████████
███████████████░██
██████████
CRYPTO CASINO &
SPORTS BETTING
▄▄███████▄▄
▄███████████████▄
███████████████████
█████████████████████
███████████████████████
█████████████████████████
█████████████████████████
█████████████████████████
███████████████████████
█████████████████████
███████████████████
▀███████████████▀
█████████
.
SuiMikira
Member
**
Offline Offline

Activity: 364
Merit: 10


View Profile
September 22, 2018, 06:13:02 AM
 #3

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
kochua
Jr. Member
*
Offline Offline

Activity: 98
Merit: 1


View Profile
September 22, 2018, 08:46:04 AM
 #4

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.
oneblagobl
Jr. Member
*
Offline Offline

Activity: 378
Merit: 1


View Profile
September 22, 2018, 09:24:25 AM
 #5

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
PowerLaunch (OP)
Copper Member
Newbie
*
Offline Offline

Activity: 50
Merit: 0

www.PowerLaunch.io


View Profile WWW
October 02, 2018, 06:21:23 PM
 #6

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.

Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!