Last active
September 10, 2019 11:45
-
-
Save nmarley/735ed56df9fdaf655463c1564058c903 to your computer and use it in GitHub Desktop.
Ethereum public key hex string to address
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var eu = require('ethereumjs-util') | |
var uncompressed_public_key_hex = '04320c6bb9c30cd4ee54484ad10b01d2742105a70b9333b2310be8e870344f18f23d70897cf0588510fc28cf76b637902179cc2d3ead649718bef61c6eb95cec7e' | |
var upk_buf = new Buffer(uncompressed_public_key_hex, 'hex') | |
var addr_buf = eu.pubToAddress(upk_buf.slice(1,65)) | |
var addr = addr_buf.toString('hex') | |
console.log("addr: " + eu.toChecksumAddress(addr) ) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks, that solution helped me!