How to convert Ethereum address to Checksum address
You can convert either an upper or lower case Ethereum address to Checksum address.
Code Example
code:example.js
let lowerCaseAddress = "0x0089d53f703f7e0843953d48133f74ce247184c2"
let upperCaseAddress = "0x0089D53F703F7E0843953D48133F74CE247184C2"
console.log(Web3.utils.toChecksumAddress(lowerCaseAddress))
// => 0x0089d53F703f7E0843953D48133f74cE247184c2
console.log(Web3.utils.toChecksumAddress(upperCaseAddress))
// => 0x0089d53F703f7E0843953D48133f74cE247184c2
Working Demo
https://piyolab.github.io/sushiether/RunScrapboxCode/?web3=1.0.0-beta.33&code=https://scrapbox.io/api/code/sushiether/web3.js_-_Ethereum_のアドレスをチェックサム付きアドレスに変換する/demo.js
Notes
Input can be with/without 0x prefix, but Output always has 0x prefix.
References
web3.js - Ethereum のアドレスをチェックサム付きアドレスに変換する
https://github.com/ethereum/EIPs/blob/master/EIPS/eip-55.md
Support
If you find this article is helpful, it would be greatly appreciated if you could tip Ether to the address below. Thank you!
0x0089d53F703f7E0843953D48133f74cE247184c2
#english #medium