I'm working with web3 1.0.0-beta.33, truffle-contract 3.0.5 and have noticed that when obtaining the list of accounts from my current web3 provider, addresses are in mixed-case as per the web3 1.0 documentation. When storing the msg.sender of my contract instantiation the address is stored as lower-case only. When i call the mycontract.creator() it returns the correct account. Tried doing it with and without metamask, truffle-contract, even switched between ganache-cli and my own geth node. Each time it has set the creator account as lower-case. Here is the account list obtained from Firefox with metamask accounts with metamask

here is the account list obtained from Chrome without metamask (provider is ganache-cli) accounts without metamask as you can see all account addresses are mixed-case, as expected in both cases, so I assume web3 is not the issue here.

The account comparison from the browser to the left is the one stored by my contract and the other one is obtained with web3.eth.getAccounts()[0]

firefox-metamask accounts stored chrome-ganache obtained accounts from Chrome

These are the test results in which addresses are stored as expected Test with ganache-cli ^ using ganache-cli

Test with geth node ^ using my own private network with geth nodes Weird thing is that during my tests address stored by the contract are mixed-case

here is my contract code (the relevant parts)

pragma solidity ^0.4.18;

contract Ive {

address public creator;
address public owner;

constructor () public {
    creator = msg.sender;
    owner = msg.sender;

function setOwner(address _owner) external {
    owner = _owner;
    // allowVisitor(_owner);
    // emit OwnerAssigned(msg.sender, _owner);

  • Hi I'm stranger about this issue so much.... but a... I will going to stay strict "Hi" and "hi" deifferences Anyway You are doing is really difficult programing thing. I can catch you up XD Anyway GLHF and If you could having a good day is my pleasure :) Commented Jun 28, 2018 at 6:38

1 Answer 1


Contracts don't store addresses in mixed case ever. That's because addresses are a hex representation of 20 bytes (and bytes don't have cases). The mixed case doesn't actually change the address at all, it is just a way of writing down the hex representation of an address that includes a checksum.

So whether a web3 call to a contract gives you back mixed case doesn't have anything to do with the contract, it has to do with the library you use to get the data from the contract. You can use web3.utils.toChecksumAddress to convert an address in upper/lower case to mixed case: https://web3js.readthedocs.io/en/1.0/web3-utils.html#tochecksumaddress

Also note that metamask uses web3 0.20.x which (afaik) doesn't use mixed case addresses by default, or is at least inconsistent.

  • This might also be related: github.com/ethereum/web3.js/issues/1395 Commented Jun 29, 2018 at 9:00
  • After reading both of your posts i can really point out the issue, is that when comparing the stored address on the contract with the transaction sending account this case-differences are making ownership validation fail. Indeed is related to the issue @leberknecht linked
    – Roberto C.
    Commented Jun 29, 2018 at 16:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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