How to import raw private keys into Parity?
Intro
In this post we will go over importing an existing ethereum account into Parity. Unfortunately there is no standard for exporting and importing ethereum accounts between MetaMask, Geth and Parity, table below summarizes what is currently supported by the software:
Metamask | go-ethereum | parity | ||
---|---|---|---|---|
private key | import / export | +/+ | +/- | -/- |
keystore file | import / export | +/- | +/+ | +/ |
What is a keystore file?
A Ethereum keystore file is a file in JSON format which is an encrypted version of your unique Ethereum private key. Together with a passphrase this file forms the private key. For this exact reason it is safer to access your funds with a keystore file and a passphrase, rather than directly with an unencrypted private key.
Prerequisites
You will need a browser with a MetaMask extension, and an ethereum account created. We will assume this account belongs to the ethereum Ropsten testnet, but exactly the same steps can be followed for a mainnet account.
You will also need geth ethereum implementation, which you can install with:
sudo add-apt-repository -y ppa:ethereum/ethereum
sudo apt-get update
sudo apt-get install ethereum
Finally you need Parity installed and on you PATH
.
Exporting MetaMask private key
From MetaMask select Export private key:
Copy the private key and paste it into a file called pass.txt
Import the private key to geth
Import the accounts private key into geth:
geth --testnet account import ~/pass.txt
Geth will prompt (twice) for a passphrase to encypt the keystore file. Choose, or better yet generate, and store it offline with a password manager.
Geth will create a keystore file in ~/.ethereum/testnet/keystore/
Import the keystore file into parity
You can now use the import
command to import the keystore file into parity, which expects a path to the directory containing the file(s):
parity --chain=ropsten account import ~/.ethereum/testnet/keystore/
for MacOS:
parity --chain=ropsten account import ./Library/Ethereum/testnet/keystore
If you see:
1 account(s) imported
That means everything went fine.
Parity stores the keystore files in:
/.local/share/io.parity.ethereum/keys/test
Go ahead and start syncing the chain.
To unlock the account you will need to paste the passphrase into a separate tet file pass.txt
and give parity the path to it:
parity --chain=ropsten --unlock 0x76136f7a41e4cec95f1dffe5a8cf4a73bcd5727b --password ~/pass.txt
NOTE
You can feed you account with some fake ETH using the testnet faucet here: https://faucet.ropsten.be/