EVM based blockchains checksummed addresses and EIP-1991

Jeremy Then
Web3 Magazine
Published in
3 min readMay 31, 2022
Photo by Batyrkhan Shalgimbekov on Unsplash

Here is the preview of a simple tool I created to convert multiple addresses to checksummed addresses for different networks: https://htmlpreview.github.io/?https://github.com/jeremythen/evm-checksum-address-converter/blob/main/index.html

Repo: https://github.com/jeremythen/evm-checksum-address-converter

Making some transactions in the RSK blockchain (an EVM compatible blockchain) using Metamask and Web3js, I noticed that the checksummed address shown in Metamask and Web3js did not match with the checksummed address in the RSK block explorer.

Metamask and Web3 produced the same checksummed address, while RSK explorer showed the same address, but with a different checksum.

Address without checksum (all lowercase):

0x3a29282d5144cea68cb33995ce82212f4b21ccec

Checksummed address from Metamask and Web3:

0x3A29282d5144cEa68cb33995Ce82212f4B21ccEc

Checksummed address from RSK explorer:

0x3a29282D5144cea68Cb33995cE82212F4B21CcEC

If we put all of them together, in order:

0x3a29282d5144cea68cb33995ce82212f4b21ccec
0x3A29282d5144cEa68cb33995Ce82212f4B21ccEc
0x3a29282D5144cea68Cb33995cE82212F4B21CcEC

With the uppercase characters of the checksum for the RSK and Metamask address highlighted in red, We notice that the checksum for the Metamask/Web3 vs the checksum for the RSK explorer is different, even though is the same address.

This difference is because of the Ethereum Improvement Proposal 1991 (EIP-1991). It proposes a way to create different checksummed addresses for EVM-compatible blockchains.

We could say that the EIP-1991 is an extension of the EIP-55 (discussed here: Ethereum checksummed addresses, importance, and implementation).

With EIP-1991, we can create checksummed addresses for specific blockchains. This way, we minimize the chances of users accidentally sending funds to a blockchain that was not intended. For example, if I intend to send some funds to an Ethereum address and I accidentally copy the RSK address instead, if the address is checksummed based on the chain it belongs to, if I try to send funds to it to a different chain, then the blockchain client will complain that the address is not valid. Effectively saving me from potentially losing funds.

But how does EIP-1991 creates different checksummed addresses for different compatible chains?

In a previous article, I discussed EIP-55 and how Ethereum checksummed addresses are created, which is:

  1. Get the Keccack-256 hash of the address in lowercase, without the ‘0x’ prefix.
  2. Compare the ith character of both the address and the hash and if the ith character of the address is a letter and the ith character of the hash hex value is greater or equal to 8, set the ith character of the address to uppercase.

EIP-1991 does exactly the same, but before hashing the address, it prepends the chain id and the ‘0x’ prefix.

With only EIP-55, it would be:

With EIP-1991, it would be:

Ethereum’s Mainnet chain ID is 1, but Ethereum clients do not implement EIP-1991, so only EIP-55 applies to Ethereum addresses.

RSK implements EIP-1991. RSK testnet chainId is 31.

You can see more EVM-compatible chain ids here: chainlist.org

Here is a code snippet implemented in Nodejs that shows a simple way to implement EIP-55 checksummed addresses with EIP-1991 in a compatible way with those EVM-compatible chains that don’t implement EIP-1991.

This would print:

checkSummedFromRskBlockExplorer === resultForRsk:  true
checkSummedFromMetamask === resultForMetamask: true
resultForRsk === resultForMetamask: false

Because the algorithm successfully created a different checksummed version for the same address, based on the chain ID.

The last line is false because the checksum for the same address for different chains would be different, effectively protecting the user from accidentally sending funds to the wrong chain.

If I try to send funds to Ethereum with an address checksummed with RSK chain ID, Metamask complains about it and doesn’t allow me to send funds to it:

Every EVM-compatible chain that implements EIP-55 and EIP-1991 usually have utilities and libraries to handle their own specific checksum addresses.

See the full code on Github here.

--

--

Jeremy Then
Web3 Magazine

I’m a full stack software developer and blockchain engineer, passionate about helping others learn software and achieve more.