Developers Forum for XinFin XDC Network

Daniel Liu
Daniel Liu

Posted on

How to export private key from keystore

The best solution is use command ethkey from XDC, the format is:

./ethkey inspect --private <KEYSTORE_FILENAME>
Enter fullscreen mode Exit fullscreen mode

eg:

./ethkey inspect --private \
${HOME}/.XDC/keystore/UTC--2023-03-30T10-33-35.502212159Z--xdc292e37DF073E885EA3C173173cCE40A6A532be9f
Enter fullscreen mode Exit fullscreen mode

Image description

To avoid entering a password, we can pass the password by using the --passwordfile flag, the format is:

./ethkey inspect --private --passwordfile <PASSWORD_FILENAME> <KEYSTORE_FILENAME>
Enter fullscreen mode Exit fullscreen mode

eg:

./ethkey inspect --private --passwordfile pw.txt \
${HOME}/.XDC/keystore/UTC--2023-03-30T10-33-35.502212159Z--xdc292e37DF073E885EA3C173173cCE40A6A532be9f
Enter fullscreen mode Exit fullscreen mode

Image description

Here the file pw.txt contains the password of keystore.

Discussion (2)

Collapse
sean_ profile image
Sean

which program are we expected to run this command in?

Collapse
gzliudan profile image
Daniel Liu Author

If you created an account with command XDC account new and you need private key of this account.