File "/usr/local/lib/python3.11/dist-packages/web3/_utils/transactions.py", line 76, in <lambda> + (2 * w3.eth.get_block("latest")["baseFeePerGas"]) ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/dist-packages/web3/eth/eth.py", line 409, in get_block return self._get_block(block_identifier, full_transactions) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/dist-packages/web3/module.py", line 75, in caller result = w3.manager.request_blocking( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/dist-packages/web3/manager.py", line 325, in request_blocking response = self._make_request(method, params) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/dist-packages/web3/manager.py", line 213, in _make_request return request_func(method, params) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/dist-packages/web3/middleware/gas_price_strategy.py", line 101, in middleware return make_request(method, params) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/dist-packages/web3/middleware/formatting.py", line 126, in middleware response = make_request(method, params) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/dist-packages/web3/middleware/attrdict.py", line 43, in middleware response = make_request(method, params) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/dist-packages/web3/middleware/formatting.py", line 128, in middleware return _apply_response_formatters( ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "cytoolz/functoolz.pyx", line 263, in cytoolz.functoolz.curry.__call__ File "/usr/local/lib/python3.11/dist-packages/web3/middleware/formatting.py", line 74, in _apply_response_formatters return _format_response("result", result_formatters[method]) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/dist-packages/web3/middleware/formatting.py", line 70, in _format_response response, response_type, method_response_formatter(appropriate_response) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "cytoolz/functoolz.pyx", line 263, in cytoolz.functoolz.curry.__call__ File "/usr/local/lib/python3.11/dist-packages/eth_utils/applicators.py", line 85, in apply_formatter_if return formatter(value) ^^^^^^^^^^^^^^^^ File "cytoolz/functoolz.pyx", line 263, in cytoolz.functoolz.curry.__call__ File "/usr/local/lib/python3.11/dist-packages/eth_utils/functional.py", line 47, in inner return callback(fn(*args, **kwargs)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/dist-packages/eth_utils/applicators.py", line 97, in apply_formatters_to_dict yield key, formatters[key](item) ^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/dist-packages/web3/middleware/validation.py", line 76, in _check_extradata_length raise ExtraDataLengthError(web3.exceptions.ExtraDataLengthError: The field extraData is 97 bytes, but should be 32. It is quite likely that you are connected to a POA chain. Refer to http://web3py.readthedocs.io/en/stable/middleware.html#proof-of-authority for more details. The full extraData is: HexBytes('0xd7..........e01')
fromuniswapimportUniswapfromweb3importWeb3wallet_address='0x05...F22'private_key='64....'router_address='0x8837a61644d523Cbe5216dDe226F8F85e3aA9be3'agc_token=Web3.to_checksum_address('0x2ad2934d5bfb7912304754479dd1f096d5c807da')matic_token=Web3.to_checksum_address('0x0000000000000000000000000000000000000000')infura_eth_mainnet="https://mainnet.infura.io/v3/..."infura_polygon_mainnet="https://polygon-mainnet.infura.io/v3/..."uniswap=Uniswap(address=wallet_address,private_key=private_key,version=3,provider=infura_polygon_mainnet)agc=uniswap.get_price_input(Web3.to_checksum_address(matic_token),Web3.to_checksum_address(agc_token),Web3.to_wei(1,'ether'))print(Web3.from_wei(agc,'ether'))output=uniswap.make_trade_output(agc_token,matic_token,1*10**18)fromptpython.replimportembedembed(globals(),locals()) Upto print() it works but trade fails |