Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error in web3.py package #3092

Closed
mrjha4050 opened this issue Sep 7, 2023 · 2 comments
Closed

Error in web3.py package #3092

mrjha4050 opened this issue Sep 7, 2023 · 2 comments

Comments

@mrjha4050
Copy link

Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/eth_account/account.py", line 799, in _parsePrivateKey
    return self._keys.PrivateKey(HexBytes(key))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/eth_keys/datatypes.py", line 251, in __init__
    validate_private_key_bytes(private_key_bytes)
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/eth_keys/validation.py", line 89, in validate_private_key_bytes
    validate_bytes_length(value, 32, "private key")
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/eth_keys/validation.py", line 54, in validate_bytes_length
    raise ValidationError(
eth_utils.exceptions.ValidationError: Unexpected private key length: Expected 32, but got 16 bytes

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/Users/naman/Dapp/deploy.py", line 14, in <module>
    acct = w3.eth.account.from_key(private_key)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/eth_utils/decorators.py", line 18, in _wrapper
    return self.method(obj, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/eth_account/account.py", line 264, in from_key
    key = self._parsePrivateKey(private_key)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/eth_utils/decorators.py", line 18, in _wrapper
    return self.method(obj, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/eth_account/account.py", line 801, in _parsePrivateKey
    raise ValueError(
ValueError: The private key must be exactly 32 bytes long, instead of 32 bytes.

I've been using the web3.y package with the Infura API, and I keep getting this error. Can somebody assist me in resolving this issue?

@pacrob
Copy link
Contributor

pacrob commented Sep 7, 2023

Per the error, it looks like you've used an invalid value for your private key:

Unexpected private key length: Expected 32, but got 16 bytes

We prefer to use issues for problems with the library itself, but you can check out our Discord for help with usage questions.

If there is a problem with the library, please open a new issue with more information.

@pacrob pacrob closed this as not planned Won't fix, can't repro, duplicate, stale Sep 7, 2023
@mrjha4050
Copy link
Author

mrjha4050 commented Sep 8, 2023 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants