EIP 1191: Add chain id to mixed-case checksum address encoding Source

AuthorJuliano Rizzo
TypeStandards Track
Requires 55, 155

Simple Summary

This EIP extends EIP-55 by optionally adding a chain id defined by EIP-155 to the checksum calculation.


Convert the address using the same algorithm defined by EIP-55 but if a registered chain id is provided, add it to the input of the hash function. If the chain id passed to the function belongs to a network that opted for using this checksum variant, prefix the address with the chain id and the 0x separator before calculating the hash. Then convert the address to hexadecimal, but if the ith digit is a letter (ie. it’s one of abcdef) print it in uppercase if the 4*ith bit of the calculated hash is 1 otherwise print it in lowercase.



  • By means of a minimal code change on existing libraries, users are protected from losing funds by mixing addresses of different Ethereum based networks.

    Backwards Compatibility

    This proposal is fully backward compatible. The checksum calculation is changed only for new networks that choose to adopt this EIP and add their chain numbers to the Adoption Table included in this document.


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 out

Test Cases

eth_mainnet= [
rsk_mainnet = [
rsk_testnet= [
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) )


Adoption Table

| Network | Chain id | Supports this EIP | |————–|———-|——————-| | RSK Mainnet | 30 | Yes | | RSK Testnet | 31 | Yes |

Implementation Table

| Wallet | Adopted this EIP | Implementation | |—————-|——————| ————– | | MyCrypto | Yes | JavaScript | | MyEtherWallet | Yes | JavaScript | | Ledger | Yes | C | | Trezor | Yes | Python and C |

Copyright and related rights waived via CC0.