0

I would like to import as well as delete the private key from go-ethereum (geth), using the web3.py client. Can you please suggest the appropriate functions? I have already generated the private key.

TylerH
  • 20,799
  • 66
  • 75
  • 101
kulls
  • 845
  • 2
  • 12
  • 37

1 Answers1

0

The web3.py docs on using private keys has this example:

with open('~/.ethereum/keystore/UTC--...--5ce9454909639D2D17A3F753ce7d93fa0b9aB12E') as keyfile:
    encrypted_key = keyfile.read()
    private_key = w3.eth.account.decrypt(encrypted_key, 'correcthorsebatterystaple')
    # tip: do not save the key or password anywhere, especially into a shared source file

The process to "import as well as delete the private key from geth" is:

  1. Identify where geth is storing your network data
  2. Look in the keystore folder in the geth data directory
  3. Choose the key file with the account that you want to export (the address is in the key name)
  4. Decrypt it locally with w3.eth.account.decrypt(...)
  5. Save a backup of the private key somewhere safe and recoverable
  6. Test recovery of the private key from your backup
  7. Remove the key file from your geth data directory
carver
  • 2,229
  • 12
  • 28