Hacktoberfest 2026:維護者為十月標記出來的 issue,仍然開放、適合新手。 瀏覽 Hacktoberfest issue

invalid token address for eth

未關閉
#229 1 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

維護者通常 1 天內回覆

還沒有人認領這個 Issue。

評估

難度
3/5
預估耗時
1-2 天
新手友好度
35/100
Issue 類型
缺陷
描述清晰度
基本清楚
活躍度
停滯
技術堆疊
python

研究方向

Start with examples/price_impact.py and trace the v3 call to estimate_price_impact, which fails when get_token receives the zero address. Check how the example sets the ETH input token and how that address is handled. Done means the ETH-to-VXV example returns a price impact without raising InvalidToken.

由索引模型根據 Issue 內容生成。

描述

bug

To Reproduce
Run the code in examples/price_impact.py

Expected behavior
Get the price impact of a swap eth to vxv

** Actual behaviour **

$ PROVIDER='http://127.0.0.1:8545' python test.py 
Impact for buying VXV on v2 with 10.0 USDT:  100%
Impact for buying VXV on v2 with 13900.0 USDT:  100%
Exception occurred while trying to get token 0x0000000000000000000000000000000000000000: Could not transact with/call contract function, is contract deployed correctly and chain synced?
Traceback (most recent call last):
  File "/path/.local/lib/python3.10/site-packages/web3/contract.py", line 1513, in call_contract_function
    output_data = web3.codec.decode_abi(output_types, return_data)
  File "/path/.local/lib/python3.10/site-packages/eth_abi/codec.py", line 181, in decode_abi
    return decoder(stream)
  File "/path/.local/lib/python3.10/site-packages/eth_abi/decoding.py", line 127, in __call__
    return self.decode(stream)
  File "/path/.local/lib/python3.10/site-packages/eth_utils/functional.py", line 45, in inner
    return callback(fn(*args, **kwargs))
  File "/path/.local/lib/python3.10/site-packages/eth_abi/decoding.py", line 173, in decode
    yield decoder(stream)
  File "/path/.local/lib/python3.10/site-packages/eth_abi/decoding.py", line 127, in __call__
    return self.decode(stream)
  File "/path/.local/lib/python3.10/site-packages/eth_abi/decoding.py", line 142, in decode
    start_pos = decode_uint_256(stream)
  File "/path/.local/lib/python3.10/site-packages/eth_abi/decoding.py", line 127, in __call__
    return self.decode(stream)
  File "/path/.local/lib/python3.10/site-packages/eth_abi/decoding.py", line 198, in decode
    raw_data = self.read_data_from_stream(stream)
  File "/path/.local/lib/python3.10/site-packages/eth_abi/decoding.py", line 305, in read_data_from_stream
    raise InsufficientDataBytes(
eth_abi.exceptions.InsufficientDataBytes: Tried to read 32 bytes.  Only got 0 bytes

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

Traceback (most recent call last):
  File "/path/.local/lib/python3.10/site-packages/uniswap/uniswap.py", line 1217, in get_token
    _name = token_contract.functions.name().call()
  File "/path/.local/lib/python3.10/site-packages/web3/contract.py", line 957, in call
    return call_contract_function(
  File "/path/.local/lib/python3.10/site-packages/web3/contract.py", line 1530, in call_contract_function
    raise BadFunctionCallOutput(msg) from e
web3.exceptions.BadFunctionCallOutput: Could not transact with/call contract function, is contract deployed correctly and chain synced?

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/path/test.py", line 62, in <module>
    eth_to_vxv_v3()
  File "/path/test.py", line 52, in eth_to_vxv_v3
    impact = uniswap.estimate_price_impact(eth, vxv, qty, fee=10000)
  File "/path/.local/lib/python3.10/site-packages/uniswap/uniswap.py", line 1351, in estimate_price_impact
    cost_amount / (amount_in / (10 ** self.get_token(token_in).decimals))
  File "/path/.local/lib/python3.10/site-packages/uniswap/uniswap.py", line 1224, in get_token
    raise InvalidToken(address)
uniswap.exceptions.InvalidToken: Invalid token address: 0x0000000000000000000000000000000000000000
主要語言
Python
星號
1k
分支
373
平均合併
2 天 6 小時
30 天內合併 PR
6

環境準備

這個專案沒有提供開發容器、Dockerfile 或貢獻指南,環境需要你自己搭建:先看它的 README,通用步驟見我們的新手貢獻指南。

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

uniswap-python/uniswap-python 的其他 Issue

查看 uniswap-python/uniswap-python 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。