I know that if I run Hardhat node, I will be provided with the addresses and private keys of the Hardhat provided accounts, like this:

Hardhat Accounts
Account #0: 0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266 (10000 ETH)
Private Key: 0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80

Account #1: 0x70997970c51812dc3a010c7d01b50e0d17dc79c8 (10000 ETH)
Private Key: 0x59c6995e998f97a5a0044966f0945389dc9e86dae88c7a8412f4603b6b78690d

Account #2: 0x3c44cdddb6a900fa2b585dd299e03d12fa4293bc (10000 ETH)
Private Key: 0x5de4111afa1a4b94908f83103eb1f1706367c2e68ca870fc3fb9a804cdab365a

Are the public keys for these accounts as easily accessible as these? I am currently attempting to generate them via some libraries, but wanted to make sure I am not wasting my time if there is somewhere I can just pull them from. I have looked around and haven't them, but perhaps they are out there somewhere.

  • "Are the public keys for these accounts as easily accessible as these?" Can you tell why do you need a public key and not just an address? Commented Sep 17, 2021 at 23:39
  • 1
    I am following a tutorial for a library that is supposed to send an encrypted message between addresses. The sender sends an object with the encrypted message and the recipient's public key. Then it can only be decrypted with the public key's corresponding private key. And since I am testing the library in Hardhat test, I would like to try to use it with the Hardhat accounts. This is my first time experimenting with private-public key pairs like this, so I hope I am thinking about this correctly.
    – Roberto
    Commented Sep 17, 2021 at 23:46
  • You can always generate the public key from the private key yourself. However Ethereum wallets and blockchain does not expose public keys unless the address has done at least one transaction, so the model you are describing might have challengers in practice. Commented Sep 18, 2021 at 8:25
  • Yeah, it seems I may have to. Maybe just do a quick ETH transfer function, then derive the public key after the transaction. I attempted importing another library that derives public keys from private keys, but when I tried deriving an address from the private keys, it didn't match the addresses provided from Hardhat. So I thought something was up. Thank you for the insight.
    – Roberto
    Commented Sep 19, 2021 at 0:06

3 Answers 3


You can derive the public key from the private key.

With ethers 5.x:

const privateKey = '0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80';
const signingKey = new ethers.utils.SigningKey(privateKey);


If you want a programmatic way to retrieve the private key, check this answer: How to get private key from hardhat ethers signer?


If you look at the source of hardhat.config.ts you will find the following fragment of code that retrieves all the node's addresses:

task("accounts", "Prints the list of accounts", async (taskArgs, hre) => {
  const accounts = await hre.ethers.getSigners();

  for (const account of accounts) {
  • public key != address
    – Rob
    Commented Jun 23, 2023 at 16:50
  • So where's the public key?
    – Mouradif
    Commented Aug 5, 2023 at 13:24

import { call } from '@wagmi/core' import { config } from './config'

await call(config, { account: '0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266', data: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2', to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8', })

  • Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.
    – Community Bot
    Commented Apr 15 at 11:03

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.