Skip to content

Instantly share code, notes, and snippets.

@nmarley
Last active September 10, 2019 11:45
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nmarley/735ed56df9fdaf655463c1564058c903 to your computer and use it in GitHub Desktop.
Save nmarley/735ed56df9fdaf655463c1564058c903 to your computer and use it in GitHub Desktop.
Ethereum public key hex string to address
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) )
@AwesomeVinc
Copy link

Thanks, that solution helped me!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment