Introduction
Hi, I'm cardene, a software engineer and technical writer focused on blockchain and AI.
I've also authored Japanese technical books on specification-driven development with LLMs and decentralized application (DApp) development.
I also build and publish a variety of tools, libraries, and open-source projects.
This article examines ERC-1191, which proposes incorporating the chain ID into Ethereum address checksums.
This explanation translates, summarizes, and expands on the original proposal.
As of December 30, 2023, ERC-1191 was at the Last Call stage.
I have also written about other ERCs.
Abstract
This proposal aims to make transferring funds on Ethereum safer. The original EIP-55 scheme uses mixed-case letters to help users detect mistakes before sending funds to an address.
ERC-1191 extends that approach by incorporating the chain ID defined in EIP-155 into the checksum calculation. Chain IDs distinguish Ethereum-compatible networks, including mainnets and testnets. Including this identifier can reduce the risk of accidentally sending funds on a different network, such as confusing an address intended for a testnet with one intended for a mainnet.
The chain-aware checksum provides an additional safeguard when wallets and applications support the scheme.
Checksums
An Ethereum address contains 40 hexadecimal characters, drawn from digits 0 through 9 and letters a through f, usually preceded by 0x. For example, an abbreviated address might look like 0x123abc.... Because addresses are long and contain similar-looking characters, typing errors can be difficult to spot. Checksums help detect them.
What is a checksum?
A checksum provides additional information for checking the accuracy of an address. EIP-55 encodes the checksum by varying the capitalization of hexadecimal letters, reducing the chance of accidental transfers to mistyped addresses.
Example
Consider an address beginning with 0xabcdef123456.... Applying a checksum might produce a representation such as 0xAbCdEf123456.... In this illustrative example, a, c, and e become uppercase, while b, d, and f stay lowercase.
Capitalization is based on a hash of the address. The scheme uses Keccak-256 and examines the relevant hash bits to decide whether each letter should be uppercase or lowercase.
Why does it matter?
If a user mistypes an address, a wallet or application can issue a warning when checksum validation fails. Entering S instead of 5, for example, would also fail basic hexadecimal-format validation.
Ethereum address checksums are widely used to reduce the risk of address-entry errors.
For more about EIP-55, see the following article.
[EIP55] How Ethereum address checksums work
For more about EIP-155, see the following article.
[EIP155] How Ethereum prevents cross-chain transaction replay
Motivation
The proposal helps software distinguish addresses intended for different Ethereum-compatible networks, including production and test networks. An ordinary Ethereum address does not encode a chain ID; its raw hexadecimal representation alone cannot identify the intended network. Users can therefore accidentally send funds on a network other than the one they intended.
ERC-1191 extends EIP-55 so that the checksum can carry information about the intended network. Software can check the address against the expected network's checksum convention and warn users about a mismatch. This can reduce accidental cross-network transfers, although it does not change the underlying address or uniquely prove network membership.
Specification
The scheme uses the existing EIP-55 checksum procedure, with an additional step for networks adopting ERC-1191: the chain ID becomes part of the hash input.
For an adopting network, prepend the decimal chain ID and 0x to the lowercase hexadecimal address before hashing. Each alphabetic hexadecimal character (abcdef) is then capitalized according to the corresponding bit of the hash output.
The relevant bit comes from the calculated hash, not from the original address.
Consider an abbreviated address a1b2c3 and an illustrative hash beginning with 3f2a1b....
For the first character a, the high bit of the corresponding hexadecimal hash digit determines capitalization. A bit value of 1 makes the letter uppercase (A); a bit value of 0 leaves it lowercase (a).
The Japanese original describes a position derived from the numerical value of the letter (10 for a). That description does not match the reference implementation below, which pairs address characters and hash digits by position. The abbreviated strings in this example are illustrative rather than actual test vectors.
The same process applies to the remaining characters, producing a mixed-case address such as A1B2c3. This provides another check on the address and the intended network.
With this approach, supporting software can validate an address against a particular network's checksum convention and reduce accidental transfers on unintended networks.
Rationale
A benefit of the proposal is that existing software can add chain-aware checksums with a small implementation change. This gives applications a way to warn users who confuse addresses intended for different Ethereum-compatible networks, such as mainnets and testnets. Such checks can help prevent the loss of funds through accidental transfers.
Implementation
#!/usr/bin/python3
from sha3 import keccak_256
import random
"""
addr (str): Hexadecimal address, 40 characters long with 2 characters prefix
chainid (int): chain id from EIP-155 """
def eth_checksum_encode(addr, chainid=1):
adopted_eip1191 = [30, 31]
hash_input = str(chainid) + addr.lower() if chainid in adopted_eip1191 else addr[2:].lower()
hash_output = keccak_256(hash_input.encode('utf8')).hexdigest()
aggregate = zip(addr[2:].lower(),hash_output)
out = addr[:2] + ''.join([c.upper() if int(a,16) >= 8 else c for c,a in aggregate])
return outThis Python script defines eth_checksum_encode, a function that applies an Ethereum address checksum. It uses special handling for RSK Mainnet and RSK Testnet, whose chain IDs are 30 and 31 respectively.
Function
- Name
eth_checksum_encode
- Arguments
addr- The Ethereum address to checksum, consisting of 40 hexadecimal characters preceded by
0x.
- The Ethereum address to checksum, consisting of 40 hexadecimal characters preceded by
chainid- The chain ID defined in EIP-155.
- Defaults to
1(Ethereum Mainnet).
Procedure
-
Check whether EIP-1191 applies
- Determine whether the chain ID is one of the networks adopting EIP-1191 in this implementation (
30or31). - If so, concatenate the chain ID and the address for the hash input.
- Otherwise, use the address without its
0xprefix.
- Determine whether the chain ID is one of the networks adopting EIP-1191 in this implementation (
-
Calculate the hash
- Use
keccak_256to hash the resulting string. - The hash determines the capitalization of the address characters.
- Use
-
Apply the checksum
- Pair each hexadecimal address character with its corresponding hash digit.
- Uppercase the character if the numerical value of that hash digit is at least 8; otherwise, leave it lowercase.
-
Generate the output
- Join the transformed characters to form the checksummed address.
- Return the result with the original
0xprefix.
Summary
The function applies the conventional Ethereum checksum, with chain-specific hashing for networks adopting ERC-1191. Applications can use this behavior to detect checksum mismatches associated with the intended network.
Tests
eth_mainnet = [
"0x27b1fdb04752bbc536007a920d24acb045561c26",
"0x3599689E6292b81B2d85451025146515070129Bb",
"0x42712D45473476b98452f434e72461577D686318",
"0x52908400098527886E0F7030069857D2E4169EE7",
"0x5aAeb6053F3E94C9b9A09f33669435E7Ef1BeAed",
"0x6549f4939460DE12611948b3f82b88C3C8975323",
"0x66f9664f97F2b50F62D13eA064982f936dE76657",
"0x8617E340B3D01FA5F11F306F4090FD50E238070D",
"0x88021160C5C792225E4E5452585947470010289D",
"0xD1220A0cf47c7B9Be7A2E6BA89F429762e7b9aDb",
"0xdbF03B407c01E7cD3CBea99509d93f8DDDC8C6FB",
"0xde709f2102306220921060314715629080e2fb77",
"0xfB6916095ca1df60bB79Ce92cE3Ea74c37c5d359",
]
rsk_mainnet = [
"0x27b1FdB04752BBc536007A920D24ACB045561c26",
"0x3599689E6292B81B2D85451025146515070129Bb",
"0x42712D45473476B98452f434E72461577d686318",
"0x52908400098527886E0F7030069857D2E4169ee7",
"0x5aaEB6053f3e94c9b9a09f33669435E7ef1bEAeD",
"0x6549F4939460DE12611948B3F82B88C3C8975323",
"0x66F9664f97f2B50F62d13EA064982F936de76657",
"0x8617E340b3D01Fa5f11f306f4090fd50E238070D",
"0x88021160c5C792225E4E5452585947470010289d",
"0xD1220A0Cf47c7B9BE7a2e6ba89F429762E7B9adB",
"0xDBF03B407c01E7CD3cBea99509D93F8Dddc8C6FB",
"0xDe709F2102306220921060314715629080e2FB77",
"0xFb6916095cA1Df60bb79ce92cE3EA74c37c5d359",
]
rsk_testnet = [
"0x27B1FdB04752BbC536007a920D24acB045561C26",
"0x3599689e6292b81b2D85451025146515070129Bb",
"0x42712D45473476B98452F434E72461577D686318",
"0x52908400098527886E0F7030069857D2e4169EE7",
"0x5aAeb6053F3e94c9b9A09F33669435E7EF1BEaEd",
"0x6549f4939460dE12611948b3f82b88C3c8975323",
"0x66f9664F97F2b50f62d13eA064982F936DE76657",
"0x8617e340b3D01fa5F11f306F4090Fd50e238070d",
"0x88021160c5C792225E4E5452585947470010289d",
"0xd1220a0CF47c7B9Be7A2E6Ba89f429762E7b9adB",
"0xdbF03B407C01E7cd3cbEa99509D93f8dDDc8C6fB",
"0xDE709F2102306220921060314715629080e2Fb77",
"0xFb6916095CA1dF60bb79CE92ce3Ea74C37c5D359",
]
test_cases = {30 : rsk_mainnet, 31 : rsk_testnet, 1 : eth_mainnet}
for chainid, cases in test_cases.items():
for addr in cases:
assert ( addr == eth_checksum_encode(addr,chainid) )This test verifies whether eth_checksum_encode produces the expected checksummed addresses for three Ethereum-compatible networks: Ethereum Mainnet, RSK Mainnet, and RSK Testnet.
Script
-
Address lists
eth_mainnet- Addresses for Ethereum Mainnet.
rsk_mainnet- Addresses for RSK Mainnet.
rsk_testnet- Addresses for RSK Testnet.
-
Test configuration
test_cases- Maps each chain ID to its corresponding address list.
- The chain IDs are
1for Ethereum Mainnet,30for RSK Mainnet, and31for RSK Testnet.
-
Running the tests
- The
forloops iterate over the chain IDs and their corresponding addresses. - For each address, call
eth_checksum_encodeand use anassertstatement to compare the returned address with the expected input address. - A mismatch raises an error and causes the test to fail.
- The
Summary
The test checks whether the function applies the expected checksum convention for each network. If every assertion passes, the function produces the expected results for these test vectors.
Usage
The following tables reproduce the adoption information presented in the original article, not a new assessment of current project support.
Usage Table
| Network | Chain id | Supports this EIP |
|---|---|---|
| RSK Mainnet | 30 | Yes |
| RSK Testnet | 31 | Yes |
Implementation Table
| Project | EIP Usage | Implementation |
|---|---|---|
| MyCrypto | Yes | JavaScript |
| MyEtherWallet | Yes | JavaScript |
| Ledger | Yes | C |
| Trezor | Yes | Python and C |
| Web3.js | Yes | JavaScript |
| EthereumJS-util | Yes | JavaScript |
| ENS address-encoder | Yes | TypeScript |
Citation
Juliano Rizzo (@juli), "ERC-1191: Add chain id to mixed-case checksum address encoding [DRAFT]," Ethereum Improvement Proposals, no. 1191, March 2018. [Online serial]. Available: https://eips.ethereum.org/EIPS/eip-1191.
Conclusion
ERC-1191 proposes incorporating the chain ID into mixed-case Ethereum address checksums. For applications supporting the proposal, this provides an additional safeguard when handling addresses intended for different networks.
If you have questions, feel free to contact me via Twitter.
I also share technical content on the following platforms.


