简体   繁体   English

如何使用Web3客户端将私钥导入到以太币中

[英]how to Import private key into geth ethereum using web3 client

I would like to import as well as delete the private key from go-ethereum ( geth ), using the web3.py client. 我想使用web3.py客户端从go-ethereum( geth )导入以及删除私钥。 Can you please suggest the appropriate functions? 您能否建议适当的功能? I have already generated the private key. 我已经生成了私钥。

Thanks, Raja K 谢谢,Raja K

The web3.py docs on using private keys has this example: 有关使用私钥web3.py文档包含以下示例:

 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: “从geth导入和删除私钥”的过程是:

  1. Identify where geth is storing your network data 确定geth将网络数据存储在何处
  2. Look in the keystore folder in the geth data directory 查看geth数据目录中的keystore文件夹
  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(...) 使用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 从您的geth数据目录中删除密钥文件

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM