Search code examples
ethereumweb3jsmetamask

MetaMask address vs Ethereum formatted address


When I get an Ethereum address from a smart contract using web3 it looks like this:

0xD034739C2aE807C70Cd703092b946f62a49509D1

But when I get it from MetaMask it looks like this:

0xd034739c2ae807c70cd703092b946f62a49509d1

I do understand these are basically the same, but:

  1. Is the MetaMask address always ALL lower case?
  2. Is there an easy way to convert the MetaMask address to the Ethereum format?
  3. Why is the difference, and what is the thinking for MM to not use Ethereum format?

Solution

  • Ethereum addresses are actually case-insensitive. So both are correct. But the address that you call the "ethereum address" is just an address that contain a check-sum. You can read more about it in eip-55 "Mixed-case checksum address encoding" and MetaMask is one of the wallet that do support the mixed-case checksum addresses completely.

    For the second question, you can just use web3.utils.toChecksumAddress('0xd034739c2ae807c70cd703092b946f62a49509d1');

    in order to convert it to a checksum address.