I know there are ways to get public key from private key using other then web3js tools (EthereumJS: How to get public key from private key and https://kobl.one/blog/create-full-ethereum-keypair-and-address/) Also, there is a way to get public key from address having a transaction sent from that address – Get public key of any ethereum account

I am looking for a way to get public key using web3js. Is there a way to do it?

  • What data you have? If you have the private key the first question should be good, if you have a signed transaction the second is correct. If you have the UTC or JSON file you canuse the first after loading the file with a wallet.
    – Ismael
    Commented Mar 7, 2018 at 19:53
  • I have all of them, but I cannot find a way to get public key using web3.js only.
    – user652061
    Commented Mar 8, 2018 at 7:53
  • I'm afraid that both versions of web3 (v0.20 and v1.0) do not expose the public key, only the private key and the address. You will need a third party library like ethereumjs-wallet that implements a getPublicKey() function.
    – Ismael
    Commented Mar 8, 2018 at 13:45

1 Answer 1


Yes, you can retrieve public key given you have a private key using web3js web3.eth.accounts.privateKeyToAccount(privateKey);

  • 11
    The documentation doesn't show a way to get the public key only the address and private key.
    – Ismael
    Commented May 7, 2019 at 17:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.