Why does web3js 0.20.6 returns all-lowercase addresses on contract creation not a checksumed address?!
How to deal with this trouble?
Ethereum Stack Exchange is a question and answer site for users of Ethereum, the decentralized application platform and smart contract enabled blockchain. It only takes a minute to sign up.
Sign up to join this communityWhy does web3js 0.20.6 returns all-lowercase addresses on contract creation not a checksumed address?!
How to deal with this trouble?
You can use
web3.utils.toChecksumAddress
EDIT: Sorry, just saw you mean 0.20.6, so its:
web3.toChecksumAddress()
I think that was not supported in web3 0.x , try to implement the function by yourself
found this code hier eip-55
const createKeccakHash = require('keccak')
function toChecksumAddress (address) {
address = address.toLowerCase().replace('0x', '')
var hash = createKeccakHash('keccak256').update(address).digest('hex')
var ret = '0x'
for (var i = 0; i < address.length; i++) {
if (parseInt(hash[i], 16) >= 8) {
ret += address[i].toUpperCase()
} else {
ret += address[i]
}
}
return ret
}