Skip to content
This repository has been archived by the owner on Jun 13, 2022. It is now read-only.

miguelmota/ethereum-public-key-to-address

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ethereum-public-key-to-address

Convert an Ethereum public key to an address

License NPM version

Demo

https://lab.miguelmota.com/ethereum-public-key-to-address

Install

npm install ethereum-public-key-to-address

Getting started

const publicKeyToAddress = require('ethereum-public-key-to-address')

console.log(publicKeyToAddress(Buffer.from('04e68acfc0253a10620dff706b0a1b1f1f5833ea3beb3bde2250d5f271f3563606672ebc45e0b7ea2e816ecb70ca03137b1c9476eec63d4632e990020b7b6fba39', 'hex'))) // '0x90F8bf6A479f320ead074411a4B0e7944Ea8c9C1'
console.log(publicKeyToAddress('04e68acfc0253a10620dff706b0a1b1f1f5833ea3beb3bde2250d5f271f3563606672ebc45e0b7ea2e816ecb70ca03137b1c9476eec63d4632e990020b7b6fba39')) // '0x90F8bf6A479f320ead074411a4B0e7944Ea8c9C1'
console.log(publicKeyToAddress('0x04e68acfc0253a10620dff706b0a1b1f1f5833ea3beb3bde2250d5f271f3563606672ebc45e0b7ea2e816ecb70ca03137b1c9476eec63d4632e990020b7b6fba39')) // '0x90F8bf6A479f320ead074411a4B0e7944Ea8c9C1'

CLI

Install:

npm install -g ethereum-public-key-to-address

Convert public key to address:

$ ethereum_public_key_to_address 04e68acfc0253a10620dff706b0a1b1f1f5833ea3beb3bde2250d5f271f3563606672ebc45e0b7ea2e816ecb70ca03137b1c9476eec63d4632e990020b7b6fba39

0x90F8bf6A479f320ead074411a4B0e7944Ea8c9C1

Piping public key example:

$ echo 04e68acfc0253a10620dff706b0a1b1f1f5833ea3beb3bde2250d5f271f3563606672ebc45e0b7ea2e816ecb70ca03137b1c9476eec63d4632e990020b7b6fba39 | ethereum_public_key_to_address

0x90F8bf6A479f320ead074411a4B0e7944Ea8c9C1

Test

npm test

License

MIT