Web3.js: Public address received from private key is not the same as real address

Created on 6 Oct 2017  路  3Comments  路  Source: ChainSafe/web3.js

I have generated new address with __MyEtherWallet__ and received private key. When I have tried to execute this code:

var from = web3.eth.accounts.privateKeyToAccount(ETH_OWNER_PRIVATE);
console.log(from);

I have noticed that from.address value is not the same as my address for this private key.
I am confused. What can it be?

Thanks!

Most helpful comment

Looks like private key should starts with 0x prefix for the correct work.

All 3 comments

Looks like private key should starts with 0x prefix for the correct work.

@dzarezenko you save me a lot of time!! thanks

Wow, I lost a lot of time in this: why not emitting a simple warning when prv key doesn't start with 0x?

Was this page helpful?
0 / 5 - 0 ratings