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

ValueError: {'code': -32000, 'message': 'transaction type not supported'} #2222

Closed
pepelax opened this issue Nov 25, 2021 · 4 comments
Closed

Comments

@pepelax
Copy link

pepelax commented Nov 25, 2021

  • Version: 5.25.0
  • Python: 3.9
  • OS: linux
  • pip freeze output
absl-py==1.0.0
aiodns==3.0.0
aiohttp==3.8.1
aiosignal==1.2.0
antlr4-python3-runtime==4.8
argon2-cffi==21.1.0
async-generator==1.10
async-timeout==4.0.1
attrs==21.2.0
backcall @ file:///home/conda/feedstock_root/build_artifacts/backcall_1592338393461/work
backports.functools-lru-cache @ file:///home/conda/feedstock_root/build_artifacts/backports.functools_lru_cache_1618230623929/work
bandit==1.7.1
base58==2.1.1
beautifulsoup4==4.10.0
bitarray==1.2.2
bleach==4.1.0
Bottleneck @ file:///home/conda/feedstock_root/build_artifacts/bottleneck_1636024229570/work
brotlipy @ file:///home/conda/feedstock_root/build_artifacts/brotlipy_1636012194889/work
cachetools==4.2.4
ccxt==1.61.59
certifi==2021.10.8
cffi @ file:///home/conda/feedstock_root/build_artifacts/cffi_1636046055389/work
chardet @ file:///home/conda/feedstock_root/build_artifacts/chardet_1635814836324/work
charset-normalizer @ file:///home/conda/feedstock_root/build_artifacts/charset-normalizer_1626371162869/work
click==7.1.2
colorama @ file:///home/conda/feedstock_root/build_artifacts/colorama_1602866480661/work
commonmark==0.9.1
conda==4.10.3
conda-package-handling @ file:///home/conda/feedstock_root/build_artifacts/conda-package-handling_1636021710069/work
configparser==5.1.0
crayons==0.4.0
cryptography @ file:///home/conda/feedstock_root/build_artifacts/cryptography_1636040644060/work
cycler @ file:///home/conda/feedstock_root/build_artifacts/cycler_1635519461629/work
Cython==0.29.24
cytoolz==0.11.2
debugpy @ file:///home/conda/feedstock_root/build_artifacts/debugpy_1636043249011/work
decorator @ file:///home/conda/feedstock_root/build_artifacts/decorator_1631346842025/work
defusedxml==0.7.1
dependency-injector==4.20.2
docker==4.4.4
einops==0.3.2
entrypoints @ file:///home/conda/feedstock_root/build_artifacts/entrypoints_1605121927639/work/dist/entrypoints-0.3-py2.py3-none-any.whl
eth-abi==2.1.1
eth-account==0.5.6
eth-hash==0.3.2
eth-keyfile==0.5.1
eth-keys==0.3.3
eth-rlp==0.2.1
eth-typing==2.2.2
eth-utils==1.10.0
evdev==1.4.0
filelock==3.4.0
frozenlist==1.2.0
fsspec==2021.11.0
future==0.18.2
gitdb==4.0.9
GitPython==3.1.24
google-auth==2.3.3
google-auth-oauthlib==0.4.6
greenlet @ file:///tmp/build/80754af9/greenlet_1628888132713/work
grpcio==1.42.0
h11==0.12.0
hexbytes==0.2.2
huggingface-hub==0.1.2
idna==2.10
importlib-metadata==4.8.2
ipfshttpclient==0.8.0a2
IProgress==0.4
ipykernel @ file:///home/conda/feedstock_root/build_artifacts/ipykernel_1636571214433/work/dist/ipykernel-6.5.0-py3-none-any.whl
ipython @ file:///home/conda/feedstock_root/build_artifacts/ipython_1636764703066/work
ipython-genutils==0.2.0
ipywidgets==7.6.5
jedi @ file:///home/conda/feedstock_root/build_artifacts/jedi_1635824010494/work
Jinja2==3.0.3
joblib==1.0.1
json5==0.9.6
jsonschema==3.2.0
jupyter-client @ file:///home/conda/feedstock_root/build_artifacts/jupyter_client_1633454794268/work
jupyter-core @ file:///home/conda/feedstock_root/build_artifacts/jupyter_core_1636814260563/work
jupyterlab-pygments==0.1.2
jupyterlab-widgets==1.0.2
kiwisolver @ file:///home/conda/feedstock_root/build_artifacts/kiwisolver_1635836719639/work
lean==1.0.72
lru-dict==1.1.7
lxml==4.6.4
Markdown==3.3.6
MarkupSafe==2.0.1
maskpass==0.3.5
matplotlib @ file:///home/conda/feedstock_root/build_artifacts/matplotlib-suite_1636786646663/work
matplotlib-inline @ file:///home/conda/feedstock_root/build_artifacts/matplotlib-inline_1631080358261/work
mistune==0.8.4
more-itertools==8.10.0
multiaddr==0.0.9
multidict==5.2.0
nbclient==0.5.9
nbconvert==6.3.0
nbformat==5.1.3
nest-asyncio @ file:///home/conda/feedstock_root/build_artifacts/nest-asyncio_1617163391303/work
netaddr==0.8.0
notebook==6.4.6
numexpr @ file:///home/conda/feedstock_root/build_artifacts/numexpr_1636286792193/work
numpy @ file:///home/conda/feedstock_root/build_artifacts/numpy_1636145338621/work
oauthlib==3.1.1
olefile @ file:///home/conda/feedstock_root/build_artifacts/olefile_1602866521163/work
omegaconf==2.1.1
outcome==1.1.0
packaging==21.2
pandas==1.3.4
pandocfilters==1.5.0
parsimonious==0.8.1
parso @ file:///home/conda/feedstock_root/build_artifacts/parso_1617148930513/work
pbr==5.7.0
pexpect @ file:///home/conda/feedstock_root/build_artifacts/pexpect_1602535608087/work
pickleshare @ file:///home/conda/feedstock_root/build_artifacts/pickleshare_1602536217715/work
Pillow @ file:///home/conda/feedstock_root/build_artifacts/pillow_1636558800840/work
prometheus-client==0.12.0
prompt-toolkit @ file:///home/conda/feedstock_root/build_artifacts/prompt-toolkit_1636045889479/work
protobuf==3.19.1
psutil==5.8.0
ptyprocess @ file:///home/conda/feedstock_root/build_artifacts/ptyprocess_1609419310487/work/dist/ptyprocess-0.7.0-py2.py3-none-any.whl
pyasn1==0.4.8
pyasn1-modules==0.2.8
pycares==4.1.2
pycosat @ file:///home/conda/feedstock_root/build_artifacts/pycosat_1636020362356/work
pycparser @ file:///home/conda/feedstock_root/build_artifacts/pycparser_1636257122734/work
pycryptodome==3.11.0
pydantic==1.7.4
pyDeprecate==0.3.1
Pygments @ file:///home/conda/feedstock_root/build_artifacts/pygments_1629119114968/work
pynput==1.7.5
pyOpenSSL @ file:///home/conda/feedstock_root/build_artifacts/pyopenssl_1633192417276/work
pyparsing==2.4.7
PyQt5==5.12.3
PyQt5_sip==4.19.18
PyQtChart==5.12
PyQtWebEngine==5.12.1
pyrsistent==0.18.0
pyshortcuts==1.8.0
PySocks @ file:///home/conda/feedstock_root/build_artifacts/pysocks_1635862404942/work
python-certifi-win32==1.6
python-dateutil @ file:///home/conda/feedstock_root/build_artifacts/python-dateutil_1626286286081/work
python-xlib==0.31
pytorch-lightning==1.5.2
pytz @ file:///home/conda/feedstock_root/build_artifacts/pytz_1633452062248/work
PyYAML==6.0
pyzmq @ file:///home/conda/feedstock_root/build_artifacts/pyzmq_1635877397296/work
quantconnect-stubs==13242
regex==2021.11.10
requests==2.25.1
requests-oauthlib==1.3.0
rich==9.10.0
rlp==2.0.1
rsa==4.7.2
ruamel-yaml-conda @ file:///home/conda/feedstock_root/build_artifacts/ruamel_yaml_1636009144459/work
rudalle==0.0.1rc1
sacremoses==0.0.46
selenium==4.0.0
Send2Trash==1.8.0
setuptools-scm==6.3.2
six==1.15.0
smmap==5.0.0
sniffio==1.2.0
sortedcontainers==2.4.0
soupsieve==2.3.1
SQLAlchemy @ file:///tmp/build/80754af9/sqlalchemy_1626947882125/work
stevedore==3.5.0
taming-transformers==0.0.1
tensorboard==2.7.0
tensorboard-data-server==0.6.1
tensorboard-plugin-wit==1.8.0
terminado==0.12.1
testpath==0.5.0
tokenizers==0.10.3
tomli==1.2.2
toolz==0.11.2
torch==1.10.0
torchmetrics==0.6.0
torchvision==0.11.1
tornado @ file:///home/conda/feedstock_root/build_artifacts/tornado_1635819584296/work
tqdm @ file:///home/conda/feedstock_root/build_artifacts/tqdm_1632160078689/work
traitlets @ file:///home/conda/feedstock_root/build_artifacts/traitlets_1635260543454/work
transformers==4.10.3
trio==0.19.0
trio-websocket==0.9.2
typing-extensions==3.10.0.2
urllib3 @ file:///home/conda/feedstock_root/build_artifacts/urllib3_1632350318291/work
varint==1.0.2
wcwidth @ file:///home/conda/feedstock_root/build_artifacts/wcwidth_1600965781394/work
web3==5.25.0
webdriver-manager==3.5.2
webencodings==0.5.1
websocket-client==1.2.1
websockets==9.1
Werkzeug==2.0.2
wget==3.2
widgetsnbextension==3.5.2
wrapt==1.12.1
wsproto==1.0.0
yarl==1.6.3
youtokentome==1.0.6
zipp==3.6.0

What was wrong?

I'm trying to send some BNB from one account to another in Binanse Smart Chain but I get 'transaction type not supported' error message.

from web3 import Web3

REF_ADDRESS = '0x5...'
MY_ADDRESS = '0xe...'
MY_PKEY = 'd...'
MAX_GAS_ETHER = 0.0005

web3 = Web3(Web3.HTTPProvider('https://bsc-dataseed.binance.org/'))

balance = web3.eth.get_balance(MY_ADDRESS)
gas_price = float(web3.fromWei(web3.eth.gas_price, 'ether'))
allowed_gas = int(MAX_GAS_ETHER/gas_price)
print(web3.fromWei(balance, 'ether'))

tx = {
    'from': MY_ADDRESS,
    'to': REF_ADDRESS,
    'value': web3.toWei(0.0001, 'ether'),
    'gas': allowed_gas,
    'type': 2,
    'chainId': web3.eth.chain_id,
    'maxFeePerGas': web3.toWei(250, 'gwei'),
    'maxPriorityFeePerGas': web3.toWei(2, 'gwei'),
    'nonce': web3.eth.get_transaction_count(MY_ADDRESS),
    }

tx_signed = web3.eth.account.sign_transaction(tx, MY_PKEY)
tx_hash = web3.eth.send_raw_transaction(tx_signed.rawTransaction)
tx_receipt = web3.eth.wait_for_transaction_receipt(tx_hash)
  • The full output of the error
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
~/dev/projects/xeon/bscscan/web3_tx.py in <module>
     26     }
     27 tx_signed = web3.eth.account.sign_transaction(tx, MY_PKEY)
---> 28 tx_hash = web3.eth.send_raw_transaction(tx_signed.rawTransaction)
     29 tx_receipt = web3.eth.wait_for_transaction_receipt(tx_hash)

~/miniconda3/lib/python3.9/site-packages/web3/eth.py in send_raw_transaction(self, transaction)
    720 
    721     def send_raw_transaction(self, transaction: Union[HexStr, bytes]) -> HexBytes:
--> 722         return self._send_raw_transaction(transaction)
    723 
    724     def sign_munger(

~/miniconda3/lib/python3.9/site-packages/web3/module.py in caller(*args, **kwargs)
     55             return LogFilter(eth_module=module, filter_id=err.filter_id)
     56         result_formatters, error_formatters, null_result_formatters = response_formatters
---> 57         result = w3.manager.request_blocking(method_str,
     58                                              params,
     59                                              error_formatters,

~/miniconda3/lib/python3.9/site-packages/web3/manager.py in request_blocking(self, method, params, error_formatters, null_result_formatters)
    196         """
    197         response = self._make_request(method, params)
--> 198         return self.formatted_response(response,
    199                                        params,
    200                                        error_formatters,

~/miniconda3/lib/python3.9/site-packages/web3/manager.py in formatted_response(self, response, params, error_formatters, null_result_formatters)
    169         if "error" in response:
    170             apply_error_formatters(error_formatters, response)
--> 171             raise ValueError(response["error"])
    172         # NULL_RESPONSES includes None, so return False here as the default
    173         # so we don't apply the null_result_formatters if there is no 'result' key

ValueError: {'code': -32000, 'message': 'transaction type not supported'}
  • I connect HTTP Node.
@pepelax
Copy link
Author

pepelax commented Nov 25, 2021

Well, I solved the issue by changing transaction values from

tx = {
    'from': MY_ADDRESS,
    'to': REF_ADDRESS,
    'value': web3.toWei(0.0001, 'ether'),
    'gas': allowed_gas,
    'type': 2,
    'chainId': web3.eth.chain_id,
    'maxFeePerGas': web3.toWei(250, 'gwei'),
    'maxPriorityFeePerGas': web3.toWei(2, 'gwei'),
    'nonce': web3.eth.get_transaction_count(MY_ADDRESS),
    }

to

tx = {
    'nonce': web3.eth.get_transaction_count(MY_ADDRESS),
    'to': REF_ADDRESS,
    'value': web3.toWei(0.001, 'ether'),
    'gas': allowed_gas,
    'gasPrice': web3.eth.gas_price
}

the documentation says

gasPrice: integer - Integer of the gasPrice used for each paid gas LEGACY - unless you have a good reason to use gasPrice, use maxFeePerGas and maxPriorityFeePerGas instead

and the provided example doesn't use gasPrice value

>>> signed_txn = w3.eth.account.sign_transaction(dict(
    nonce=w3.eth.get_transaction_count(public_address_of_senders_account),
    maxFeePerGas=3000000000,
    maxPriorityFeePerGas=2000000000,
    gas=100000,
    to='0xd3CdA913deB6f67967B99D67aCDFa1712C293601',
    value=12345,
    data=b'',
    type=2,  # (optional) the type is now implicitly set based on appropriate transaction params
    chainId=1,
  ),
  private_key_for_senders_account,
)
>>> w3.eth.send_raw_transaction(signed_txn.rawTransaction)
HexBytes('0xe670ec64341771606e55d6b4ca35a1a6b75ee3d5145a99d05921026d1527331')

But it doesn't work in this manner (

@fselmo
Copy link
Collaborator

fselmo commented Nov 26, 2021

@mzaprudin Thanks for reaching out. It's important to note that the module these methods exist within is the eth module. This is going to be solely driven by and expected to support Ethereum clients. Ethereum recently introduced the London hard fork and EIP-1559 was one of these changes. EIP-1559 introduced support for a type=2 transaction where the max fee fields replace the gas price field. Not all chains will have this support. I suspect most won't.

It looks like you are connecting to BSC which does not support a type=2 transaction that I am aware of. So using gasPrice instead of the EIP-1559 max fees is the way to go here. I'm glad you were able to resolve this. I'm going to close this ticket but if you find there is still a relevant error here please feel free to re-open.

@fselmo fselmo closed this as completed Nov 26, 2021
@061official
Copy link

@mzaprudin Thanks for reaching out. It's important to note that the module these methods exist within is the eth module. This is going to be solely driven by and expected to support Ethereum clients. Ethereum recently introduced the London hard fork and EIP-1559 was one of these changes. EIP-1559 introduced support for a type=2 transaction where the max fee fields replace the gas price field. Not all chains will have this support. I suspect most won't.

It looks like you are connecting to BSC which does not support a type=2 transaction that I am aware of. So using gasPrice instead of the EIP-1559 max fees is the way to go here. I'm glad you were able to resolve this. I'm going to close this ticket but if you find there is still a relevant error here please feel free to re-open.

@mzaprudin @fselmo first of all thanks for this thread.
I have faced the same issue as mzaprudin for BSC testenet and his solution worked for me as well.

@fselmo may i propose to include your response as a note at https://web3py.readthedocs.io/en/stable/web3.eth.html#web3.eth.Eth.send_raw_transaction as this is highly useful information.

@fselmo
Copy link
Collaborator

fselmo commented Jan 4, 2022

Hey @061official. This is good feedback.I think it's pretty explicit that the eth module should not support bsc. We are working on making it easier to import external modules into the web3 library so I think this can pave the way for others creating their own bsc module to be imported. But this repo does live within the Ethereum repositories as well.

We made a note to add a bit better messaging in general to the docs, rather than to the eth_sendRawTransaction method docs, so that we can make this a bit more clear to users of the library. Thanks for the feedback.

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

3 participants