bsc-docker
bsc-docker copied to clipboard
Executing `python3 private-key.py` gives AttributeError: 'Account' object has no attribute 'privateKeyToAccount'
I am trying to run for dev environment on Linux machine.
I found the steps are bit confusing for just running for a dev env. Additionally when I run python3 private-key.py
it gives
Traceback (most recent call last): File "/home/maltabba/repos/experiments/bsc/bsc-docker/private-key.py", line 13, in
acct = w3.eth.account.privateKeyToAccount(private_key) AttributeError: 'Account' object has no attribute 'privateKeyToAccount'
What do you suggest? Thanks,
Can you run the command from "init-holders" folder?
It produced the exact same error when running from inside init-holders
.
Updating the content of private-key.py to the following resolved the issue:
#!/usr/bin/env python3
from web3 import Web3, HTTPProvider
import os
private_keys = './init-holders'
idx = 1
w3 = Web3(HTTPProvider('http://localhost:8545', request_kwargs={'timeout': 120}))
for keystore_file in os.listdir(private_keys):
with open("%s/%s" % (private_keys, keystore_file)) as keyfile:
encrypted_file = keyfile.read()
private_key = w3.eth.account.decrypt(encrypted_file, '')
acct = w3.eth.account.from_key(private_key)
print('Account %s: %s, private key: %s' % (idx, Web3.to_checksum_address(acct.address), private_key.hex()))
idx = idx + 1
I opened a PR for this.