8

I have an error from web3:

Unhandled rejection Error: Given address "0x" is not a valid Ethereum address.

My question is if is there any tool that can fix my address (add checksum).

3
  • Looks like you're trying to pass an illegal address, without any trailing zeros. Are you trying to send to the zero address (0x0) ?
    – jojeyh
    Commented Oct 15, 2017 at 21:21
  • No I found out that etherscan.io is formatting address in correct form with checksum, but I still have warning from web3.
    – gkucmierz
    Commented Oct 15, 2017 at 21:25
  • Here is an online tool for you tokenmarket.net/ethereum-address-validator Commented Mar 15, 2018 at 8:45

7 Answers 7

11

If you prefer a simple web version, check out EthSum:

EthSum Screen Capture

Disclaimer: I'm the author, it's an open source tool.

2
  • 1
    Top notch tool, I use it all the time. But please update after an address has been checksummed to say, "this address has been checksummed" rather than "this address had already been checksummed." It was very confusing for a newbie like me. Commented Apr 7, 2020 at 11:04
  • Thanks Nic, happy that you like it! Could you clarify your issue, please? There's no "had already been checksummed" message, only "address is already checksummed" when the input address is already in the correct form. Would you rather want to see "address has been checksummed" all the time? Commented Apr 7, 2020 at 11:42
14

With web3 you can do:

web3.toChecksumAddress('INSERT ADDRESS HERE')

It will return the address with checksum

1
  • 4
    In a new version of web3 you have to use web3.utils.toChecksumAddress
    – EtherPaul
    Commented Jul 16, 2020 at 20:05
5

Yes, you can.

Replcae your address in the following url of etherscan https://etherscan.io/address/{address} like this:

you want the checksum for address 0x0fd60495d705f4fb86e1b36be396757689fbe8b3 so you need to call https://etherscan.io/address/0x0fd60495d705f4fb86e1b36be396757689fbe8b3 then copy the address with valid checksum 0x0Fd60495d705F4Fb86e1b36Be396757689FbE8B3 on the loaded page.

enter image description here

4

These are the functions you're looking for: specification of the corresponding EIP and the implementation.

1
  • Is there an interactive online version anywhere?
    – Stan James
    Commented Oct 17, 2017 at 22:38
2

ethers.js also does the job. It's more lightweight than web3.js.

// Injects the checksum (via upper-casing specific letters)
ethers.utils.getAddress("0x8ba1f109551bd432803012645ac136ddd64dba72");
// '0x8ba1f109551bD432803012645Ac136ddd64DBA72'

ethers Docs

1
  • Rather opinionated about which is more lightweight. But your answer is actually exactly what I was looking for! Commented May 15 at 21:06
1
  1. With ethers@v5
 ethers.utils.isAddress(YOUR_ADDRESS)
  1. With ethers@v6
 ethers.isAddress(YOUR_ADDRESS)
0

Adding to @3lLobo answer above on utlizing ethers.js:

ethers.js is moved from v5 to v6. So many things from v5 are no longer supported in v6 including utils. https://docs.ethers.org/v6/migrating/

https://docs.ethers.org/v6/api/address/#isAddress

Before:

ethers.utils.getAddress();

After:

ethers.getAddress();

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.