Publish your own packages to the world's most popular software ecosystem with npm Pro.Get started »

ethereum-public-key-to-address

0.0.2 • Public • Published

ethereum-public-key-to-address

Convert an Ethereum public key to an address

License NPM version

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

Install

npm i ethereum-public-key-to-address

DownloadsWeekly Downloads

279

Version

0.0.2

License

MIT

Unpacked Size

7.35 kB

Total Files

8

Last publish

Collaborators

  • avatar