When testrpc starts, it outputs the generated addresses, but all in lower case. What's a lightweight way to get their EIP55 checksummed format?


Ensure testrpc is running. From a second terminal (opened by running node), run:

> Web3 = require('web3')
> web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:8545"));

This should shoot out a list of all available commands, and leave you with a command prompt. From the prompt you can then run the appropriate command:

> web3.toChecksumAddress('0x65601db7431427e32ce2d60e6a373bc7a7f68eb4')
  • 1
    That's a better answer than mine. Particularly as "lightweight" is a criteria. – Samuel Hawksby-Robinson Mar 7 '17 at 21:09
  • web3 no longer has tochecksum address? – quantumpotato Jan 18 '18 at 20:03

In that link you supplied there is code that gives your answer:

// Make a checksum address
var toChecksumAddress = function (address) {    
    address = address.toLowerCase().replace('0x','');
    var addressHash = web3.sha3(address);
    var checksumAddress = '0x';

    for (var i = 0; i < address.length; i++ ) { 
        // If ith character is 9 to f then make it uppercase 
        if (parseInt(addressHash[i], 16) > 7) {
          checksumAddress += address[i].toUpperCase();
        } else {
            checksumAddress += address[i];
    return checksumAddress;

When you say

What's a lightweight way to get their EIP55 checksummed format?

Are you looking for lighterweight code than that?

  • That code has an error in it :-) It should be if (parseInt(addressHash[i], 16) > 7) not > 8. It might be worth grabbing the code that was committed, rather than code talked about in the thread, just to be safe. – Richard Horrocks Mar 7 '17 at 19:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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