我试图熟悉uniswap python模块,但在第一次测试时就已经卡住了。此代码来自入门指南:
from uniswap import Uniswap
address = None # or None if you're not going to make transactions
private_key = None # or None if you're not going to make transactions
version = 2 # specify which version of Uniswap to use
provider = "https://mainnet.infura.io/v3/c4bcdc3744df4340b875e095b0713258" # can also be set through the environment variable `PROVIDER`
uniswap = Uniswap(address=address, private_key=private_key, version=version, provider=provider)
# Some token addresses we'll be using later in this guide
eth = "0x0000000000000000000000000000000000000000"
bat = "0x0D8775F648430679A709E98d2b0Cb6250d2887EF"
dai = "0x6B175474E89094C44Da98b954EedeAC495271d0F"
uniswap.get_price_input(eth, dai, 10**18)
我得到这个错误:
Traceback (most recent call last):
File "c:UsersphilDesktopPythonuniswap.py", line 1, in <module>
from uniswap import Uniswap
File "c:UsersphilDesktopPythonuniswap.py", line 1, in <module>
from uniswap import Uniswap
ImportError: cannot import name 'Uniswap' from partially initialized module 'uniswap' (most likely due to a circular import) (c:UsersphilDesktopPythonuniswap.py)
您的文件名为uniswap.py
c:UsersphilDesktopPythonuniswap.py
现在CCD_ 2加载您的文件而不是模块CCD_。
只需重命名您的文件,即test-uniswap.py
。
c:UsersphilDesktopPythontest-uniswap.py