Open woshidama323 opened 1 year ago
Thanks for the report @woshidama323. We changed the private key you listed to <private key>
, even though it doesn't look like the address associated with the PK has any assets. Don't use the address associated with that PK in the future.
It does look like this is a bug, but you can work around it by converting the to address to HexBytes before sending it:
>>> from hexbytes import HexBytes
>>> stx = {'gasPrice': 5000000000, 'nonce': 431, 'to': HexBytes(0x0d8ce2a99bb6e3b7db580ed848240e4a0f9ae153), ... }
I'm going to transfer this issue to the eth-account
repo because I think that's where the actual issue is.
Adding on to this, it looks like the problem is actually that the address isn't checksummed. The error message could definitely stand to be improved here.
| File "/venv/lib/python3.11/site-packages/eth_account/signers/local.py", line 94, in sign_transaction
| return self._publicapi.sign_transaction(transaction_dict, self.key)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| File "/venv/lib/python3.11/site-packages/eth_utils/decorators.py", line 29, in _wrapper
| return self.method(obj, *args, **kwargs)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| File "/venv/lib/python3.11/site-packages/eth_account/account.py", line 772, in sign_transaction
| ) = sign_transaction_dict(account._key_obj, sanitized_transaction)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| File "/venv/lib/python3.11/site-packages/eth_account/_utils/signing.py", line 32, in sign_transaction_dict
| unsigned_transaction = serializable_unsigned_transaction_from_dict(transaction_dict)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| File "/venv/lib/python3.11/site-packages/eth_account/_utils/legacy_transactions.py", line 42, in serializable_unsigned_transaction_from_dict
| return TypedTransaction.from_dict(transaction_dict)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| File "/venv/lib/python3.11/site-packages/eth_account/_utils/typed_transactions.py", line 161, in from_dict
| transaction=transaction.from_dict(dictionary),
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| File "/venv/lib/python3.11/site-packages/eth_account/_utils/typed_transactions.py", line 492, in from_dict
| cls.assert_valid_fields(dictionary)
| File "/venv/lib/python3.11/site-packages/eth_account/_utils/typed_transactions.py", line 483, in assert_valid_fields
| raise TypeError("Transaction had invalid fields: %r" % invalid)
| TypeError: Transaction had invalid fields: {'gas': HexBytes('0xd1d8')}
+------------------------------------
Occasionally received similar error today web3.py 6.15.0 eth_account 0.10.0
pip freeze
outputWhat was wrong?
Please include any of the following that are applicable:
description: when trying to sign with sign_transaction offline, I got such errors bellow:
Here is the whole output
But if i change the to field with "0xdd8ce2a99bb6e3b7db580ed848240e4a0f9ae153" (here i changed 0x0 to 0xd) It works well
Guess the web3.py cannot handle such 0x0 prefix address well ?
How can it be fixed?
Fill this section in if you know how this could or should be fixed. None
Note: We prefer to use issues to track our work. If you think you've encountered a bug in web3py or have a feature request, you're in the right place. If you have implementation or usage questions, please refer to our documentation and/or join the conversation on discord.